Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save benthomasson/d0cfe3a0289517c0610a to your computer and use it in GitHub Desktop.

Select an option

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
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