I am using the facade-like pattern described here: http://django-tastypie.readthedocs.org/en/latest/non_orm_data_sources.html
def obj_get(self, request=None, **kwargs):
rv = MyObject(init=kwargs['pk'])
audit_trail.message( ... )
return rv
I can’t return None, tosses an error.
You should raise an exception: tastypie.exceptions.NotFound (according to the code documentation).
I am working on tastypie for CouchDB and delved into the issue. In the tastypie.resources.Resource class you can find the method that you have to override:
My example:
One thing is strange for me. When I had a look at obj_get method in ModelResource class (the superclass of Resource class):
an exception: self._meta.object_class.DoesNotExist is raised when object is not found, which eventually becomes ObjectDoesNotExist exception – so it is not consensus inside the project.