Opened 8 years ago

Closed 7 years ago

#4114 closed (wontfix)

ForeignKey and OneToOneField should take the verbose_name of target field by default

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: ForeignKey OneToOneField verbose_name
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In order to get a user-friendly and localize-ready field name in the Admin site, ForeignKey and OneToOneField should take the verbose_name of target field by default. Otherwise you'll have to write something like this:

Foo = ForeignKey(Bar, verbose_name=Bar._meta.verbose_name)

That would violate the DRY principle.

Here's a patch for Django svn revision 5056, which modifies django/db/models/fields/related.py.

Attachments (1)

related.patch (1.2 KB) - added by anonymous 8 years ago.
Patch of default verbose_name for ForeignKey and OneToOneField

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by anonymous

Patch of default verbose_name for ForeignKey and OneToOneField

comment:1 Changed 7 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Nah, this isn't a good idea. Consider:

   class Person(Model):
       hometown = ForeignKey(Place)
       birthplace = ForeignKey(Place)

Your patch would make both of these quite different fields have the same verbose_name; that's not right.

Note: See TracTickets for help on using tickets.
Back to Top