#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 , 11 years ago
follow-up: 5 comment:2 by , 11 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Unreviewed → Accepted |
This should be fixed on stacked.html
as well. It also needs tests in order to be merged.
comment:3 by , 11 years ago
Hello nofinator.
Can I help you for create tests ? :)
My mail: chexov34@…
comment:4 by , 11 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.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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 , 11 years ago
I also created a pull request if you think it's ready: https://github.com/django/django/pull/1882
comment:7 by , 11 years ago
Needs tests: | unset |
---|---|
Resolution: | fixed |
Status: | closed → new |
I think I set the resolution to fixed
prematurely.
comment:8 by , 11 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 , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.