Ticket #5373: 5373.6.diff

File 5373.6.diff, 1.5 KB (added by Roald de Vries <roald@…>, 13 years ago)

Improvement of prior solutions, but no final fix

  • django/db/models/fields/__init__.py

    diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
    index 9037265..8619008 100644
    a b class Field(object):  
    222222        return self._unique or self.primary_key
    223223    unique = property(unique)
    224224
     225    def set_verbose_name_from_name(self, name):
     226        if self.verbose_name is None and name:
     227            self.verbose_name = name.replace('_', ' ')
     228
    225229    def set_attributes_from_name(self, name):
    226230        self.name = name
    227231        self.attname, self.column = self.get_attname_column()
    228         if self.verbose_name is None and name:
    229             self.verbose_name = name.replace('_', ' ')
     232        self.set_verbose_name_from_name(name)
    230233
    231234    def contribute_to_class(self, cls, name):
    232235        self.set_attributes_from_name(name)
  • django/db/models/fields/related.py

    diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
    index cedf308..774a724 100644
    a b class RelatedField(object):  
    112112        else:
    113113            self.do_related_class(other, cls)
    114114
     115    def set_verbose_name_from_name(self, name):
     116        # for related fields, the verbose name should be set by set_attributes_from_rel
     117        pass
     118
    115119    def set_attributes_from_rel(self):
    116120        self.name = self.name or (self.rel.to._meta.object_name.lower() + '_' + self.rel.to._meta.pk.name)
    117121        if self.verbose_name is None:
Back to Top