Opened 3 years ago

Closed 3 years ago

#18571 closed Bug (wontfix)

ModelAdmin.filter_horizontal should use plural for ManyToManyField

Reported by: RoySmith Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Do something like:

class Regatta(Model):
    boat = ManyToManyField(Boat, blank=True)

class RegattaAdmin(admin.ModelAdmin):
    filter_horizontal = ['boat']

then edit a Regatta in the admin. The picker boxes will have headers "Available Boat" and "Chosen Boat". These should be plural (i.e. "Available Boats", "Chosen Boats"). Likewise for the mouseover help texts.

Change History (2)

comment:1 Changed 3 years ago by charettes

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Semantically speaking I think you should rename your Regatta.boat field to Regatta.boats.

In this case the admin accounts you are already providing a plural name since it represents a M2M relation.

comment:2 Changed 3 years ago by RoySmith

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

Hmmm. I generally follow the rule that all model names are singular, but I see in the docs it is recommended for django that ManyToMany relationships have plural names (https://docs.djangoproject.com/en/dev/topics/db/models/#many-to-many-relationships). I'm not sure I agree with that recommendation, but since it is the documented standard, I'll go with it.

Marking this "wontfix".

Last edited 3 years ago by RoySmith (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top