=== django/db/models/options.py
==================================================================
|
|
|
10 | 10 | # Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces". |
11 | 11 | get_verbose_name = lambda class_name: re.sub('([A-Z])', ' \\1', class_name).lower().strip() |
12 | 12 | |
13 | | DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering', |
| 13 | DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering', |
14 | 14 | 'unique_together', 'permissions', 'get_latest_by', |
15 | 15 | 'order_with_respect_to', 'app_label') |
16 | 16 | |
… |
… |
|
39 | 39 | self.object_name = cls.__name__ |
40 | 40 | self.module_name = self.object_name.lower() |
41 | 41 | self.verbose_name = get_verbose_name(self.object_name) |
| 42 | self.verbose_name_plural = self.verbose_name + 's' |
42 | 43 | # Next, apply any overridden values from 'class Meta'. |
43 | 44 | if self.meta: |
44 | 45 | meta_attrs = self.meta.__dict__ |
45 | 46 | del meta_attrs['__module__'] |
46 | 47 | del meta_attrs['__doc__'] |
| 48 | if 'verbose_name' in meta_attrs and 'verbose_name_plural' not in meta_attrs: |
| 49 | meta_attrs['verbose_name_plural'] = meta_attrs['verbose_name'] + 's' |
47 | 50 | for attr_name in DEFAULT_NAMES: |
48 | 51 | setattr(self, attr_name, meta_attrs.pop(attr_name, getattr(self, attr_name))) |
49 | | # verbose_name_plural is a special case because it uses a 's' |
50 | | # by default. |
51 | | setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', self.verbose_name + 's')) |
52 | 52 | # Any leftover attributes must be invalid. |
53 | 53 | if meta_attrs != {}: |
54 | 54 | raise TypeError, "'class Meta' got invalid attribute(s): %s" % ','.join(meta_attrs.keys()) |