Code

Ticket #5373: 5373.patch

File 5373.patch, 910 bytes (added by mk, 6 years ago)
  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index 439633c..82b5e6c 100644
    a b class Field(object): 
    191191    def set_attributes_from_name(self, name): 
    192192        self.name = name 
    193193        self.attname, self.column = self.get_attname_column() 
    194         self.verbose_name = self.verbose_name or (name and name.replace('_', ' ')) 
     194 
     195        from django.db.models.fields.related import RelatedField 
     196        if not isinstance(self, RelatedField): 
     197            # verbose_name for RelatedFields gets set in method set_attributes_from_rel 
     198            # of .related.RelatatedField; see ticket #5373 
     199            self.verbose_name = self.verbose_name or (name and name.replace('_', ' ')) 
    195200 
    196201    def contribute_to_class(self, cls, name): 
    197202        self.set_attributes_from_name(name)