Code

Ticket #7342: 7342-r7568.diff

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

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

Line 
1Index: django/db/models/options.py
2===================================================================
3--- django/db/models/options.py (revision 7568)
4+++ django/db/models/options.py (working copy)
5@@ -56,8 +56,12 @@
6         # Next, apply any overridden values from 'class Meta'.
7         if self.meta:
8             meta_attrs = self.meta.__dict__.copy()
9-            del meta_attrs['__module__']
10-            del meta_attrs['__doc__']
11+            for name in self.meta.__dict__:
12+                # Ignore any private attributes that Django doesn't care about.
13+                # NOTE: We can't modify a dictionary's contents while looping
14+                # over it, so we loop over the *original* dictionary instead.
15+                if name.startswith('_'):
16+                    del meta_attrs[name]
17             for attr_name in DEFAULT_NAMES:
18                 if attr_name in meta_attrs:
19                     setattr(self, attr_name, meta_attrs.pop(attr_name))