Ticket #15279: multiple_abstract_inheritance_r15458.diff

File multiple_abstract_inheritance_r15458.diff, 1.8 KB (added by Stephen Burrows, 14 years ago)
  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index fd0a295..6bfdefe 100644
    a b class Field(object):  
    234234    def contribute_to_class(self, cls, name):
    235235        self.set_attributes_from_name(name)
    236236        self.model = cls
     237        if not hasattr(self, "_declared_on_class"):
     238            self._declared_on_class = cls
     239        if not hasattr(self, "_first_concrete_class") and not cls._meta.abstract:
     240            self._first_concrete_class = cls
    237241        cls._meta.add_field(self)
    238242        if self.choices:
    239243            setattr(cls, 'get_%s_display' % self.name, curry(cls._get_FIELD_display, field=self))
  • django/db/models/options.py

    diff --git a/django/db/models/options.py b/django/db/models/options.py
    index 2f64c56..e6f286d 100644
    a b class Options(object):  
    152152        # Insert the given field in the order in which it was created, using
    153153        # the "creation_counter" attribute of the field.
    154154        # Move many-to-many related fields from self.fields into
    155         # self.many_to_many.
     155        # self.many_to_many. Ignore duplicate fields inherited from a
     156        # single abstract base class.
     157        try:
     158            f = self.get_field(field.name)
     159        except FieldDoesNotExist:
     160            pass
     161        else:
     162            if f._declared_on_class == field._declared_on_class and getattr(f, '_first_concrete_class', None) == getattr(field, '_first_concrete_class', None):
     163                return
     164
    156165        if field.rel and isinstance(field.rel, ManyToManyRel):
    157166            self.local_many_to_many.insert(bisect(self.local_many_to_many, field), field)
    158167            if hasattr(self, '_m2m_cache'):
Back to Top