[Django] #24626: widgets property doesn't work in ModelForm

8 views
Skip to first unread message

Django

unread,
Apr 10, 2015, 10:52:55 PM4/10/15
to django-...@googlegroups.com
#24626: widgets property doesn't work in ModelForm
----------------------------+--------------------
Reporter: lipemorais | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
The widgets property of the ModelForm doesn't work as expected adding a
class on the input.


{{{
from django.forms import DateField, CharField, PasswordInput, TextInput
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from login.models import Fan

class FanForm(UserCreationForm):
birthday = DateField(input_formats=['%d-%m-%Y', '%d/%m/%Y'])

class Meta:
model = Fan
fields = ['username', 'email', 'first_name', 'last_name',
'birthday', 'gender', 'password1', 'password2']
widgets = {
'username': TextInput(attrs={'data': 'meu nome', 'class': 'my-
class'}),
}
}}}

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

Django

unread,
Apr 11, 2015, 9:41:23 AM4/11/15
to django-...@googlegroups.com
#24626: widgets property doesn't work in ModelForm
----------------------------+--------------------------------------
Reporter: lipemorais | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.7
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_docs: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

It doesn't work on 1.7 because `UserCreationForm` declares the `username`
field so `Meta.widgets` doesn't have an effect for that field. It does
work on 1.8+ because the `username` field has been removed as of
849538d03df21b69f0754a38ee4ec5f48fa02c52.

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

Reply all
Reply to author
Forward
0 new messages