Ticket #7342: 7342-r7568.diff

File 7342-r7568.diff, 973 bytes (added by Gulopine, 7 years ago)

Per Jacob, this patch simply ignores any attributes beginning with _, future-proofing this considerably.

  • django/db/models/options.py

     
    5656        # Next, apply any overridden values from 'class Meta'.
    5757        if self.meta:
    5858            meta_attrs = self.meta.__dict__.copy()
    59             del meta_attrs['__module__']
    60             del meta_attrs['__doc__']
     59            for name in self.meta.__dict__:
     60                # Ignore any private attributes that Django doesn't care about.
     61                # NOTE: We can't modify a dictionary's contents while looping
     62                # over it, so we loop over the *original* dictionary instead.
     63                if name.startswith('_'):
     64                    del meta_attrs[name]
    6165            for attr_name in DEFAULT_NAMES:
    6266                if attr_name in meta_attrs:
    6367                    setattr(self, attr_name, meta_attrs.pop(attr_name))
Back to Top