diff options
| author | Tom Christie | 2011-07-01 11:31:04 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-07-01 11:31:04 +0100 |
| commit | ca4b7560cb469cc9e7f89043a6273aa969d778ca (patch) | |
| tree | 669567c3f51329e0afc7d4e975b409a57a3866fe /djangorestframework/mixins.py | |
| parent | 16d8c3255d549d410b04d86ab82d024ff2f79d66 (diff) | |
| parent | dc9960f770c6f6984ce30e3997d1db0d60829d51 (diff) | |
| download | django-rest-framework-ca4b7560cb469cc9e7f89043a6273aa969d778ca.tar.bz2 | |
merge
Diffstat (limited to 'djangorestframework/mixins.py')
| -rw-r--r-- | djangorestframework/mixins.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/djangorestframework/mixins.py b/djangorestframework/mixins.py index 9bd7598e..b1ba0596 100644 --- a/djangorestframework/mixins.py +++ b/djangorestframework/mixins.py @@ -491,17 +491,17 @@ class ReadModelMixin(object): try: if args: # If we have any none kwargs then assume the last represents the primrary key - instance = model.objects.get(pk=args[-1], **kwargs) + self.model_instance = model.objects.get(pk=args[-1], **kwargs) else: # Otherwise assume the kwargs uniquely identify the model filtered_keywords = kwargs.copy() if BaseRenderer._FORMAT_QUERY_PARAM in filtered_keywords: del filtered_keywords[BaseRenderer._FORMAT_QUERY_PARAM] - instance = model.objects.get(**filtered_keywords) + self.model_instance = model.objects.get(**filtered_keywords) except model.DoesNotExist: raise ErrorResponse(status.HTTP_404_NOT_FOUND) - return instance + return self.model_instance class CreateModelMixin(object): @@ -540,19 +540,19 @@ class UpdateModelMixin(object): try: if args: # If we have any none kwargs then assume the last represents the primrary key - instance = model.objects.get(pk=args[-1], **kwargs) + self.model_instance = model.objects.get(pk=args[-1], **kwargs) else: # Otherwise assume the kwargs uniquely identify the model - instance = model.objects.get(**kwargs) + self.model_instance = model.objects.get(**kwargs) for (key, val) in self.CONTENT.items(): - setattr(instance, key, val) + setattr(self.model_instance, key, val) except model.DoesNotExist: - instance = model(**self.CONTENT) - instance.save() + self.model_instance = model(**self.CONTENT) + self.model_instance.save() - instance.save() - return instance + self.model_instance.save() + return self.model_instance class DeleteModelMixin(object): |
