Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#21353 closed Bug (fixed)

'description' key in InlineModelAdmin fieldsets is ignored

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

Description

The InlineModelAdmin supports fieldsets, just like ModelAdmin objects. However, if you add a 'description' key, it does not appear on the rendered form.

For example:

class BookInline(admin.TabularInline):
    model = Book
    fieldsets = (
        (None, {
            'description': 'These are the related books.',
            'fields': ('name', 'date'),
        }),
    )

I would expect to see 'These are the related books.' in the tabular inline section for Books, but I don't.

(I suspect other fieldset keys are ignored in inlines, too. I haven't tried those.)

I am will share a branch with a fix for this on GitHub soon.

Change History (11)

comment:1 by Greg, 10 years ago

Here is a link to a branch with a fix in my repo: https://github.com/nofeet/django/tree/ticket_21353

It looks for and uses the description for only the first fieldset in the inline admin form. I'm not exactly sure how the inline fieldsets and forms work, so this is the cleanest fix I came across after several attempts. Perhaps someone with more knowledge can come up with a better solution.

comment:2 by Tim Graham, 10 years ago

Has patch: set
Needs tests: set
Patch needs improvement: set
Triage Stage: UnreviewedAccepted

This should be fixed on stacked.html as well. It also needs tests in order to be merged.

comment:3 by chexov34@…, 10 years ago

Hello nofinator.
Can I help you for create tests ? :)
My mail: chexov34@…

comment:4 by Greg, 10 years ago

Thanks, chexov34, but since this is my first dev work for the Django code base, I'd like to give it a try. I saw that there are already some test InlineAdmin models with fieldsets already, so I hope to write the tests within the next few days.

in reply to:  2 comment:5 by Greg, 10 years ago

Resolution: fixed
Status: newclosed

Replying to timo:

This should be fixed on stacked.html as well.

I tried out StackedInlines and they work already for fieldsets because stacked.html includes fieldset.html.

It also needs tests in order to be merged.

Ah, of course. I just pushed a test for this on my branch.

comment:6 by Greg, 10 years ago

I also created a pull request if you think it's ready: https://github.com/django/django/pull/1882

comment:7 by Greg, 10 years ago

Needs tests: unset
Resolution: fixed
Status: closednew

I think I set the resolution to fixed prematurely.

comment:8 by Tim Graham, 10 years ago

As I noticed on the pull request, fieldset.name isn't rendered either, maybe this was intentionally omitted in the tabular inline. Just stacking up the descriptions where they don't really correspond to the fields doesn't seem very elegant. It may be best just to document that description doesn't apply when using TabularInlines.

comment:9 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In d5031ecf881eaefe7ada1c35228b35a1852dd343:

Fixed #21353 -- Noted that description is ignored for TabularInlines.

Thanks nofinator for the report.

comment:10 by Tim Graham <timograham@…>, 10 years ago

In ae78227de3740cce7e2b460b2845f19443c4d090:

[1.7.x] Fixed #21353 -- Noted that description is ignored for TabularInlines.

Thanks nofinator for the report.

Backport of d5031ecf88 from master

comment:11 by Tim Graham <timograham@…>, 10 years ago

In de95867284ddf84bb4ca5e5946bae96d5d23babf:

[1.6.x] Fixed #21353 -- Noted that description is ignored for TabularInlines.

Thanks nofinator for the report.

Backport of d5031ecf88 from master

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