Opened 12 years ago

Closed 4 years ago

Last modified 4 years ago

#18549 closed Bug (fixed)

Admin should not use verbose_name_plural for OneToOne field

Reported by: Roy Smith Owned by: Tim McCurrach
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: harph, 4glitch@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
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 12 years ago.
Fixed adding two conditions to the stacked.html and tabular.html templates.

Download all attachments as: .zip

Change History (17)

comment:1 by Julien Phalip, 12 years ago

Triage Stage: UnreviewedAccepted

comment:2 by vanessagomes, 12 years ago

Owner: changed from nobody to vanessagomes

by harph, 12 years ago

Attachment: 18549.diff added

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

comment:3 by harph, 12 years ago

Has patch: set
Version: 1.4master

comment:4 by harph, 12 years ago

Cc: harph added

comment:5 by harph, 12 years ago

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

comment:6 by Claude Paroz, 12 years ago

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 by anonymous, 12 years ago

Cc: 4glitch@… added

comment:8 by Tim Graham, 11 years ago

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.

comment:9 by Mariusz Felisiak, 4 years ago

Status: newassigned

comment:10 by Mariusz Felisiak, 4 years ago

Owner: vanessagomes removed
Status: assignednew

comment:11 by Tim McCurrach, 4 years ago

Owner: set to Tim McCurrach
Status: newassigned

comment:12 by Tim McCurrach, 4 years ago

Needs tests: unset
Patch needs improvement: unset

comment:13 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:14 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 13409a0c:

Refs #18549 -- Added test for heading of foreign key inlines.

comment:15 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 0aff3fd7:

Fixed #18549 -- Fixed heading for inlines with a OneToOneField.

Used verbose_name instead of verbose_name_plural.

comment:16 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In a91bf804:

[3.2.x] Fixed #18549 -- Fixed heading for inlines with a OneToOneField.

Used verbose_name instead of verbose_name_plural.

Backport of 0aff3fd7110d1bd431a35bb28d8688693b98d886 from master.

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