mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-24 23:19:47 +03:00
Merge 5958feaa78
into 8f23b7f2f9
This commit is contained in:
commit
e787a9c761
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user