Created
February 9, 2011 15:37
-
-
Save colinsullivan/818661 to your computer and use it in GitHub Desktop.
My solution for: https://github.com/toastdriven/django-tastypie/issues/#issue/75
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0952e591e94a44afaa0ac27eff1f4f71c6423627 Mon Sep 17 00:00:00 2001 | |
From: Colin Sullivan <[email protected]> | |
Date: Tue, 8 Feb 2011 20:49:37 -0500 | |
Subject: [PATCH] Catch NotFound error instead of all errors... | |
to create resource if it doesn't exist. | |
--- | |
tastypie/resources.py | 2 +- | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
diff --git a/tastypie/resources.py b/tastypie/resources.py | |
index b481421..b76eb4e 100644 | |
--- a/tastypie/resources.py | |
+++ b/tastypie/resources.py | |
@@ -983,7 +983,7 @@ class Resource(object): | |
try: | |
updated_bundle = self.obj_update(bundle, request=request, pk=kwargs.get('pk')) | |
return HttpAccepted() | |
- except: | |
+ except NotFound: | |
updated_bundle = self.obj_create(bundle, request=request, pk=kwargs.get('pk')) | |
return HttpCreated(location=self.get_resource_uri(updated_bundle)) | |
-- | |
1.7.3.5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment