{"action":"closed","issue":{"url":"https://api.github.com/repos/greyside/django-admin-smoke-tests/issues/2","labels_url":"https://api.github.com/repos/greyside/django-admin-smoke-tests/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/greyside/django-admin-smoke-tests/issues/2/comments","events_url":"https://api.github.com/repos/greyside/django-admin-smoke-tests/issues/2/events","html_url":"https://github.com/greyside/django-admin-smoke-tests/issues/2","id":88398671,"number":2,"title":"get_absolute_url test will always fail for some models","user":{"login":"andybak","id":60035,"avatar_url":"https://avatars.githubusercontent.com/u/60035?v=3","gravatar_id":"","url":"https://api.github.com/users/andybak","html_url":"https://github.com/andybak","followers_url":"https://api.github.com/users/andybak/followers","following_url":"https://api.github.com/users/andybak/following{/other_user}","gists_url":"https://api.github.com/users/andybak/gists{/gist_id}","starred_url":"https://api.github.com/users/andybak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andybak/subscriptions","organizations_url":"https://api.github.com/users/andybak/orgs","repos_url":"https://api.github.com/users/andybak/repos","events_url":"https://api.github.com/users/andybak/events{/privacy}","received_events_url":"https://api.github.com/users/andybak/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-15T11:39:50Z","updated_at":"2016-01-22T20:44:28Z","closed_at":"2016-01-22T20:44:28Z","body":"This is probably more of a 'is this the right way to do it?' question rather than an actual bug.\r\n\r\nI've got a model with the following:\r\n\r\n    def get_absolute_url(self):\r\n        return reverse('product', kwargs={'slug': self.slug})\r\n\r\nand the following url entry:\r\n\r\n    url(r'^(?P<slug>[\\w-]+)/$', 'products.views.product', name='product')\r\n\r\nRunning smoke tests naively always fails as smoke tests will call it with a model that has no slug field set and thus slug is equal to '' which doesn't match the above rule.\r\n\r\nI can think of two ways to get round this:\r\n\r\n1. Subclass smoke tests and alter test_get_absolute_url so it supplies a slug\r\n2. Subclass smoke tests and supply a fixture\r\n3. Alter my model so that slug has a default value\r\n4. Alter my url rule to url(r'^(?P<slug>[\\w-]*)/$', 'products.views.product', name='product') - * instead of + will therefore match\r\n\r\n1 and 2 mean that I'll need a different subclass for every model - this rather defeats the object of having a single generic smoketest for the admin\r\n\r\n3 and 4 mean that I'm changing perfectly good code just to make a test pass which feels wrong too.\r\n\r\nIs there another solution I've not thought of?"}}