aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework
diff options
context:
space:
mode:
authorJosé Padilla2015-04-04 22:01:06 -0400
committerJosé Padilla2015-04-04 22:01:06 -0400
commit2e6d39dbae3330cef31d68dedd37398e364ee83c (patch)
treeb4eb15e787cc08f48caeff068d70bbb4767c559f /rest_framework
parent6333e4818860901505b36640a288f95e55e89216 (diff)
parentb1c1867b162c8eb9b7c2807029397d27a01ce19c (diff)
downloaddjango-rest-framework-2e6d39dbae3330cef31d68dedd37398e364ee83c.tar.bz2
Merge pull request #2754 from bleib1dj/enhancement_dont_require_pk_strictly_related
Enhancement dont require pk strictly related #2745
Diffstat (limited to 'rest_framework')
-rw-r--r--rest_framework/relations.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/rest_framework/relations.py b/rest_framework/relations.py
index 3a966c5b..00a4a265 100644
--- a/rest_framework/relations.py
+++ b/rest_framework/relations.py
@@ -196,7 +196,7 @@ class HyperlinkedRelatedField(RelatedField):
attributes are not configured to correctly match the URL conf.
"""
# Unsaved objects will not yet have a valid URL.
- if obj.pk is None:
+ if hasattr(obj, 'pk') and obj.pk is None:
return None
lookup_value = getattr(obj, self.lookup_field)
@@ -361,7 +361,7 @@ class ManyRelatedField(Field):
def get_attribute(self, instance):
# Can't have any relationships if not created
- if not instance.pk:
+ if hasattr(instance, 'pk') and instance.pk is None:
return []
relationship = get_attribute(instance, self.source_attrs)