[Django] #33574: SlugField in formfield_overrides

8 views
Skip to first unread message

Django

unread,
Mar 14, 2022, 4:48:17 AM3/14/22
to django-...@googlegroups.com
#33574: SlugField in formfield_overrides
-------------------------------------+-------------------------------------
Reporter: Maxim | Owner: nobody
Danilov |
Type: Bug | Status: new
Component: | Version: 4.0
contrib.admin | Keywords: admin, modeladmin,
Severity: Normal | documentation
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
ff overriding not always works in ModelAdmin.
For example, I want to have a possibility to override form field class,
like that:
{{{
formfield_overrides = { models.SlugField: {'form_class': forms.CharField}
}
}}}
its is not possible, error is "class CharField receive too much arguments
in init".
And all Django Fields with additional arguments give us this error, if
somebody want to override field_class, like in options.py in
FORMFIELD_FOR_DBFIELD_DEFAULTS

I think formfield_overrides was a wrong decision, but we have it already.
And in Documentation is not deprecated to use "form_class", that's why we
should to describe about "possible errors after field_class overriding" in
documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/33574>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 14, 2022, 5:09:09 AM3/14/22
to django-...@googlegroups.com
#33574: SlugField in formfield_overrides
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: SaNjU
| Saini
Type: Bug | Status: assigned
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution:
Keywords: admin, modeladmin, | Triage Stage:
documentation | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by SaNjU Saini):

* cc: SaNjU Saini (added)
* owner: nobody => SaNjU Saini
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/33574#comment:1>

Django

unread,
Mar 16, 2022, 4:28:29 AM3/16/22
to django-...@googlegroups.com
#33574: SlugField in formfield_overrides
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: SaNjU
| Saini
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: wontfix

Keywords: admin, modeladmin, | Triage Stage:
documentation | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: assigned => closed
* resolution: => wontfix


Comment:

Interesting example, but out of scope for `formfield_overrides`, which is
just ''a quick-and-dirty way to override **some** of the Field options for
use in the admin'' (emphasis added).

If you **really** want to use CharField here, provide a Form subclass via
`ModelAdmin.get_form()`. (Adding logic to exclude `kwargs` via
`formfield_overrides` is not going to be worth the complexity.)

--
Ticket URL: <https://code.djangoproject.com/ticket/33574#comment:2>

Django

unread,
Mar 16, 2022, 5:17:06 AM3/16/22
to django-...@googlegroups.com
#33574: SlugField in formfield_overrides
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: SaNjU
| Saini
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: wontfix
Keywords: admin, modeladmin, | Triage Stage:
documentation | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Maxim Danilov):

I think, it simply can be added in documentation in box "warning", we
already have this box.

I know Django a little bit, of course, i can change my field in many
places: in form class, in get_form method, in formfield_for_db.
Simplest way is to use "formfield_overrides", this is an attribute. But,
it is not well documented.

That's why i have started this issue and i think we should to describe


about "possible errors after field_class overriding" in documentation.

--
Ticket URL: <https://code.djangoproject.com/ticket/33574#comment:3>

Django

unread,
Mar 16, 2022, 6:25:04 AM3/16/22
to django-...@googlegroups.com
#33574: SlugField in formfield_overrides
-------------------------------------+-------------------------------------
Reporter: Maxim Danilov | Owner: SaNjU
| Saini
Type: Bug | Status: closed
Component: contrib.admin | Version: 4.0
Severity: Normal | Resolution: wontfix
Keywords: admin, modeladmin, | Triage Stage:
documentation | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

If you'd like to propose a documentation patch, then please do.

My concern would be that that it would be difficult to explain clearly,
such that it's not of benefit to add for most readers, however very happy
to consider!

--
Ticket URL: <https://code.djangoproject.com/ticket/33574#comment:4>

Reply all
Reply to author
Forward
0 new messages