This commit is contained in:
Nathan Agrin 2012-12-17 14:04:46 -08:00
commit e787a9c761
2 changed files with 5 additions and 1 deletions

View File

@ -106,6 +106,10 @@ class UpdateModelMixin(object):
# pk and/or slug attributes are implicit in the URL.
pk = self.kwargs.get(self.pk_url_kwarg, None)
if pk:
try:
pk = int(pk)
except ValueError:
pass
setattr(obj, 'pk', pk)
slug = self.kwargs.get(self.slug_url_kwarg, None)

View File

@ -175,7 +175,7 @@ class TestInstanceView(TestCase):
content = {'text': 'foobar'}
request = factory.put('/1', json.dumps(content),
content_type='application/json')
response = self.view(request, pk=1).render()
response = self.view(request, pk='1').render()
self.assertEquals(response.status_code, status.HTTP_200_OK)
self.assertEquals(response.data, {'id': 1, 'text': 'foobar'})
updated = self.objects.get(id=1)