Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#8024 closed (fixed)

Changeset 8132 breaks labels on ForeignKey Fields

Reported by: arne Owned by: Malcolm Tredinnick
Component: Uncategorized Version: master
Severity: Keywords: label, verbose_name, model
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The change in r8132 leads to empty labels in the admin change-forms if the ForeignKey Fields don't have an verbose_name parameter set.

To reproduce just create two models:

class ModelA(models.Model):
    title = models.CharField(max_length=20)

class ModelB(models.Model):
    foo = models.ForeignKey(ModelA)

and register the models with the admin app

class ModelAadmin(admin.ModelAdmin):

class ModelBadmin(admin.ModelAdmin):
    pass, ModelAadmin), ModelBadmin)

In the Admin Change-Form of ModelB an empty label is displayed on the ForeignKeyField to ModelA (only a ":" displayed, expected output would be "Model a:")

The following patch fixes the problem, but I'm not sure if it breaks the problem which should be fixed by r8132 which was reported in #8011

--- db/models/fields/	(revision 8137)
+++ db/models/fields/	(working copy)
@@ -117,7 +117,7 @@
     def set_attributes_from_rel(self): = or ( + '_' +
-        if self.verbose_name is None:
+        if not self.verbose_name:
             self.verbose_name =
         self.rel.field_name = self.rel.field_name or

Change History (4)

comment:1 Changed 10 years ago by Alex Gaynor

milestone: 1.0 beta
Triage Stage: UnreviewedAccepted

This is causing errors all over, see the buildbot.

comment:2 Changed 10 years ago by Malcolm Tredinnick

Owner: changed from nobody to Malcolm Tredinnick

comment:3 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

Jacob beat me to it (thankfully). Fixed in [8138], by the looks of it.

comment:4 Changed 7 years ago by Jacob

milestone: 1.0 beta

Milestone 1.0 beta deleted

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