diff options
| author | Ramiro Morales <ramiro@users.noreply.github.com> | 2014-05-21 18:57:46 -0300 |
|---|---|---|
| committer | Ramiro Morales <ramiro@users.noreply.github.com> | 2014-05-21 18:57:46 -0300 |
| commit | d731f48ecea6ceeabc2b015b48655a9f9428a730 (patch) | |
| tree | bc3bf8a1014d4fb2c04c0d4fd4f8e5ceb7b2845b /django | |
| parent | 64ee097b3b33716b10837644f9e18b87f25d606e (diff) | |
| parent | 862e1ff2340a1e28a3e7c6904d2b0283085f34c8 (diff) | |
Merge pull request #2679 from ramiro/t22421
Fixed #22421 -- Regression in fixtures loading.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/fields/related.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index bad457f571..ceae2cd563 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -1440,14 +1440,16 @@ class ForeignObject(RelatedField): @staticmethod def get_instance_value_for_fields(instance, fields): ret = [] + opts = instance._meta for field in fields: # Gotcha: in some cases (like fixture loading) a model can have # different values in parent_ptr_id and parent's id. So, use # instance.pk (that is, parent_ptr_id) when asked for instance.id. - opts = instance._meta if field.primary_key: possible_parent_link = opts.get_ancestor_link(field.model) - if not possible_parent_link or possible_parent_link.primary_key: + if (not possible_parent_link or + possible_parent_link.primary_key or + possible_parent_link.model._meta.abstract): ret.append(instance.pk) continue ret.append(getattr(instance, field.attname)) |
