Opened 18 years ago

Closed 17 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: dev
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: no UI/UX: no

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 18 years ago.
Patch of default verbose_name for ForeignKey and OneToOneField

Download all attachments as: .zip

Change History (2)

by anonymous, 18 years ago

Attachment: related.patch added

Patch of default verbose_name for ForeignKey and OneToOneField

comment:1 by Jacob, 17 years ago

Resolution: wontfix
Status: newclosed

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