#33703: ModelAdmin.get_fields wrong work with ModelAdmin.fieldsets statement
-----------------------------------+--------------------------------------
Reporter: Maxim Danilov | Owner: nobody
Type: Uncategorized | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: invalid
Keywords: admin, modeladmin | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):
* status: new => closed
* resolution: => invalid
Comment:
Exactly as you quoted the docs:
> The get_fields method is given the HttpRequest and the obj being edited
(or None on an add form) and is expected to **return a list of fields, as
described above in the ModelAdmin.fields** section.
and `ModelAdmin.fields`:
> **Use the fields option to make simple layout changes** in the forms on
the “add” and “change” pages such as showing only a subset of available
fields **For more complex layout needs, see the fieldsets option.**
You didn't use `ModelAdmin.fields` or overwrite `ModelAdmin.get_fields()`,
so `ModelAdmin.get_fields()` returned base fields and readonly-fields.
`ModelAdmin.get_fields()` is not described as a tool for getting displayed
fields, it's a hook to overwrite displayed fields when you need a
conditional logic based on a request and you don't use `fieldsets` for a
complex layout, not the other way around.
You can raise your doubts on the DevelopersMailingList to reach a wider
audience and see what other think, if you don't agree. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/33703#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070180bcb107c3-7e37d8f8-0c55-45d1-be9e-8b287dedfe2a-000000%40eu-central-1.amazonses.com.