1 2 3 4 5 6 7 8 9 10 11 12 | from django import forms
from django.contrib.auth.models import User
class UserForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(UserForm, self).__init__(*args, **kwargs)
# change a widget attribute:
self.fields['user_permissions'].widget.attrs["size"] = 5
class Meta:
model = User
|
More like this
- Add model form field meta data in a DRY way by jedie 4 years, 2 months ago
- Add attrs automaticlly through ModelForm field max_length by lettoo 1 year, 4 months ago
- Reorder fields directly in the ModelForm by HM 5 years ago
- filtered ModelChoiceField queries by robharvey 5 years, 2 months ago
- DisplayModelForm by koenb 5 years ago
Comments
Related: Snippet 755
#