5👍
✅
You can do it in __init__
form method:
class TestPoljaForm(ModelForm):
class Meta:
model = TestPolja
def __init__(self, *args, **kwargs):
super(TestPoljaForm, self).__init__(*args, **kwargs)
# for example change class for integerPolje1
self.fields['integerPolje1'].widget.attrs['class'] = 'SOMECLASS'
# you can iterate all fields here
for fname, f in self.fields.items():
f.widget.attrs['class'] = 'SOMECLASS'
👤ndpu
3👍
class TestPoljaForm(ModelForm):
integerPolje1 = forms.IntegerField(widget=forms.TextInput(attrs={'class': 'myclass'}))
class Meta:
model = TestPolja
- [Django]-How to update where the files are stored in Django app
- [Django]-How to stream a file in a request?
- [Django]-What does the proxy_pass option in the NGINX config do?
- [Django]-Trying to avoid circular imports
Source:stackexchange.com