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)
Change History (2)
by , 18 years ago
Attachment: | related.patch added |
---|
comment:1 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → 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.
Patch of default verbose_name for ForeignKey and OneToOneField