Opened 6 years ago
Last modified 6 years ago
#29468 closed Cleanup/optimization
Form Field declaration: — at Initial Version
Reported by: | Ivan Muller | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | Field Widget html attrs |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
Hi guys, I want to improve the way of declaring html attrs into a Fields With out declaring the default widget again.
example: class ProfileForm(forms.ModelForm): class Meta: model = Profile full_name = forms.CharField(widget=forms.TextInput(attrs={'class': Anyclass',}))
As Field documentaiton say into the init:
"""Each Field has a default Widget that it'll use if you don't specify this. n most cases, the default widget is TextInput:"""
Woudl be god to declare it as
full_name = forms.CharField(widget_attrs={'class': Anyclass',})
Note:
See TracTickets
for help on using tickets.