Code

Ticket #5817: model_meta_w_inheritance.diff

File model_meta_w_inheritance.diff, 963 bytes (added by miracle2k, 7 years ago)
Line 
1Index: options.py
2===================================================================
3--- options.py  (revision 5677)
4+++ options.py  (working copy)
5@@ -47,9 +47,13 @@
6 
7         # Next, apply any overridden values from 'class Meta'.
8         if self.meta:
9-            meta_attrs = self.meta.__dict__
10-            del meta_attrs['__module__']
11-            del meta_attrs['__doc__']
12+            # Build list of attributes - don't use __dict__, as we want to include
13+            # super class attributes as well.
14+            meta_attrs = dict([
15+                (name, getattr(self.meta, name))
16+                for name in dir(self.meta)
17+                # exclude python built-in attributes
18+                if not name.startswith('__')])
19             for attr_name in DEFAULT_NAMES:
20                 setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name)))
21             # verbose_name_plural is a special case because it uses a 's'