diff options
| author | José Padilla | 2015-04-04 22:01:06 -0400 | 
|---|---|---|
| committer | José Padilla | 2015-04-04 22:01:06 -0400 | 
| commit | 2e6d39dbae3330cef31d68dedd37398e364ee83c (patch) | |
| tree | b4eb15e787cc08f48caeff068d70bbb4767c559f /rest_framework | |
| parent | 6333e4818860901505b36640a288f95e55e89216 (diff) | |
| parent | b1c1867b162c8eb9b7c2807029397d27a01ce19c (diff) | |
| download | django-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.py | 4 | 
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) | 
