Ticket #14018: changes.diff
File changes.diff, 2.5 KB (added by , 14 years ago) |
---|
-
django/db/models/fields/related.py
97 97 if not cls._meta.abstract and self.rel.related_name: 98 98 self.rel.related_name = self.rel.related_name % { 99 99 'class': cls.__name__.lower(), 100 'class_plural': cls._meta.verbose_name_plural.lower().__str__(), 100 101 'app_label': cls._meta.app_label.lower(), 101 102 } 102 103 -
docs/topics/db/models.txt
874 874 875 875 To work around this problem, when you are using :attr:`~django.db.models.ForeignKey.related_name` in an 876 876 abstract base class (only), part of the name should contain 877 ``'%(app_label)s'`` and ``'%(class)s'``.877 ``'%(app_label)s'`` and either ``'%(class)s'`` or ``'%(class_plural)s'``. 878 878 879 879 - ``'%(class)s'`` is replaced by the lower-cased name of the child class 880 880 that the field is used in. 881 - ``'%(class_plural)s'`` is replaced by the lower-case pluralized name (as 882 defined by ``verbose_name_plural`` in the child model's inner ``Meta`` class) 883 of the child class that the field is used in. 881 884 - ``'%(app_label)s'`` is replaced by the lower-cased name of the app the child 882 885 class is contained within. Each installed application name must be unique 883 886 and the model class names within each app must also be unique, therefore the … … 908 911 ``common_childa_related``, whilst the reverse name of the 909 912 ``common.ChildB.m2m`` field will be ``common_childb_related``, and finally the 910 913 reverse name of the ``rare.ChildB.m2m`` field will be ``rare_childb_related``. 911 It is up to you how you use the ``'%(class)s'`` and ``'%(app_label)s`` portion 912 to construct your related name, but if you forget to use it, Django will raise 913 errors when you validate your models (or run :djadmin:`syncdb`). 914 It is up to you how you use the ``'%(class)s'`` (or ``'%(class_plural)s'``) and 915 ``'%(app_label)s`` portion to construct your related name, but if you forget to 916 use it, Django will raise errors when you validate your models (or run 917 :djadmin:`syncdb`). 914 918 915 919 If you don't specify a :attr:`~django.db.models.ForeignKey.related_name` 916 920 attribute for a field in an abstract base class, the default reverse name will