Forked from johanneskoch/gist:ee1288f490f8a7640207
Created
February 11, 2016 16:03
-
-
Save benthomasson/d0cfe3a0289517c0610a to your computer and use it in GitHub Desktop.
Additional patch needed to make https://gist.github.com/teeberg/87463ed0cd4dc4ceba6b work with POST-requests
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
| diff --git a/tastypie/fields.py b/tastypie/fields.py | |
| index ae3f291..568788c 100644 | |
| --- a/tastypie/fields.py | |
| +++ b/tastypie/fields.py | |
| @@ -644,7 +644,7 @@ class RelatedField(ApiField): | |
| Accepts either a URI, a data dictionary (or dictionary-like structure) | |
| or an object with a ``pk``. | |
| """ | |
| - self.fk_resource = self.to_class() | |
| + self.fk_resource = self.to_class(api_name=self.api_name) | |
| kwargs = { | |
| 'request': request, | |
| 'related_obj': related_obj, | |
| diff --git a/tastypie/resources.py b/tastypie/resources.py | |
| index 0d51a3a..5c1164e 100644 | |
| --- a/tastypie/resources.py | |
| +++ b/tastypie/resources.py | |
| @@ -859,6 +859,8 @@ class Resource(six.with_metaclass(DeclarativeMetaclass)): | |
| bundle = self.hydrate(bundle) | |
| for field_name, field_object in self.fields.items(): | |
| + field_object.api_name = self.api_name | |
| + | |
| if field_object.readonly is True: | |
| continue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment