Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#8024 closed (fixed)

Changeset 8132 breaks labels on ForeignKey Fields

Reported by: arne Owned by: mtredinnick
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 7 years ago by Alex

  • milestone set to 1.0 beta
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

This is causing errors all over, see the buildbot.

comment:2 Changed 7 years ago by mtredinnick

  • Owner changed from nobody to mtredinnick

comment:3 Changed 7 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:4 Changed 4 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

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