Why does this test not work?
This is my view.py:
class ObjectDetailView(LoginRequiredMixin, DetailView):
template_name = "object-detail.html"
model = Object
slug_field = 'username'
def dispatch(self, request, *args, **kwargs):
....
urls.py:
url(r'^object/details/(?P<slug>[-\w.]+)/$', ObjectDetailView.as_view(), name='object-details'),
tests.py:
class ObjectViewsTestCase(TestCase):
fixtures = ['/app/fixtures/object_fixture.json', ]
def test_object_details(self):
user = User.objects.get(id=1)
self.client.login(username=user.username, password=user.password)
resp = self.client.get(reverse('object-details', kwargs={'slug': user.username}))
self.assertEqual(resp.status_code, 200)
My mistake:
NoReverseMatch: the converse for 'part objects' with arguments' ()' and the keyword arguments' {'slug': u'admin '}' were not found. 0 templates (s): []
source
share