Ticket #11369: 11369-r11267.diff

File 11369-r11267.diff, 2.4 KB (added by Ramiro Morales, 15 years ago)
  • django/db/models/options.py

    diff -r 349898dd5478 django/db/models/options.py
    a b  
    1818# Calculate the verbose_name by converting from InitialCaps to "lowercase with spaces".
    1919get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', ' \\1', class_name).lower().strip()
    2020
    21 DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering',
     21DEFAULT_NAMES = ('verbose_name', 'verbose_name_plural', 'db_table', 'ordering',
    2222                 'unique_together', 'permissions', 'get_latest_by',
    2323                 'order_with_respect_to', 'app_label', 'db_tablespace',
    2424                 'abstract', 'managed', 'proxy')
     
    8989
    9090            # verbose_name_plural is a special case because it uses a 's'
    9191            # by default.
    92             setattr(self, 'verbose_name_plural', meta_attrs.pop('verbose_name_plural', string_concat(self.verbose_name, 's')))
     92            if getattr(self, 'verbose_name_plural', None) is None:
     93                setattr(self, 'verbose_name_plural', string_concat(self.verbose_name, 's'))
    9394
    9495            # Any leftover attributes must be invalid.
    9596            if meta_attrs != {}:
  • tests/regressiontests/model_inheritance_regress/models.py

    diff -r 349898dd5478 tests/regressiontests/model_inheritance_regress/models.py
    a b  
    109109    def __unicode__(self):
    110110        return "PK = %d, base_name = %s, derived_name = %s" \
    111111                % (self.customPK, self.base_name, self.derived_name)
     112
     113class AuditBase(models.Model):
     114    planned_date = models.DateTimeField()
     115
     116    class Meta:
     117        abstract = True
     118        verbose_name_plural = u'Audits'
     119
     120class CertificationAudit(AuditBase):
     121
     122    class Meta(AuditBase.Meta):
     123        abstract = True
     124
     125class InternalCertificationAudit(CertificationAudit):
     126    auditing_dept = models.CharField(max_length=20)
    112127
    113128__test__ = {'API_TESTS':"""
    114129# Regression for #7350, #7202
     
    318333>>> ParkingLot3._meta.get_ancestor_link(Place).name  # the child->parent link
    319334"parent"
    320335
     336# Regression for #11369: verbose_name_plural should be inherited from an ABC
     337# even when there is one or more additional intermediate abstract models in the
     338# inheritance chain.
     339>>> InternalCertificationAudit._meta.verbose_name_plural
     340u"Audits"
     341
    321342"""}
    322343
Back to Top