Opened 3 years ago

Last modified 23 months ago

#18549 new Bug

Admin should not use verbose_name_plural for OneToOne field

Reported by: RoySmith Owned by: vanessagomes
Component: contrib.admin Version: master
Severity: Normal Keywords:
Cc: harph, 4glitch@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Do something like the following:

class Foo(Model):
     i = IntegerField()
     bar = OneToOneField("Bar")

class FooInline(admin.TabularInline):
    model = Foo

class Bar(Model):
    i = Integerfield()

class BarAdmin(admin.ModelAdmin):
    inlines = [FooInline]

admin.site.register(Foo, FooAdmin)
admin.site.register(Bar)

When you edit a Bar in the admin, the formset section for entering a Foo will be labeled "Foos" (plural). Since it's a one-to-one mapping, it should be labeled "Foo" (singular).

Attachments (1)

18549.diff (1.9 KB) - added by harph 3 years ago.
Fixed adding two conditions to the stacked.html and tabular.html templates.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 3 years ago by julien

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 3 years ago by vanessagomes

  • Owner changed from nobody to vanessagomes

Changed 3 years ago by harph

Fixed adding two conditions to the stacked.html and tabular.html templates.

comment:3 Changed 3 years ago by harph

  • Has patch set
  • Version changed from 1.4 to master

comment:4 Changed 3 years ago by harph

  • Cc harph added

comment:5 Changed 3 years ago by harph

I submitted a pull request. This is the url: https://github.com/django/django/pull/498

comment:6 Changed 3 years ago by claudep

Note that you are hard-coding usage of plural for 0 items, which is not true for all languages. However, I'm not sure there is a better solution i18n-wise (as using blocktrans will only partially solve it and add a non-sense translatable string to po files).

comment:7 Changed 3 years ago by anonymous

  • Cc 4glitch@… added

comment:8 Changed 23 months ago by timo

  • Needs tests set
  • Patch needs improvement set

This needs tests, ideally adding max_num=1 to an existing tabular and stacked inline and verifying the <h2> text. The existing patch also causes some test failures due to the added whitespace.

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