I have a form in django and I want to attribute a class to some fields. that's because I want to use those classes in my css code and I don't want all fields have the same style.
for example my form has 2 text fields and a button. I don't want to style the text fields as same as each other. I want the first to be right-to-left and the second to be left-to-right.
we can use required_css_class = 'required' but it's just for the required fields and not for every field I want. Any ideas?
class CommentForm(forms.Form):
name = forms.CharField(
widget=forms.TextInput(attrs={'class':'special'}))
url = forms.URLField()
comment = forms.CharField(
widget=forms.TextInput(attrs={'size':'40'}))
More here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With