.
This commit is contained in:
@@ -39,3 +39,22 @@ class BackgroundImageForm(forms.ModelForm):
|
||||
'image': forms.ClearableFileInput(attrs={'class': 'file-input'}),
|
||||
'is_active': forms.CheckboxInput(attrs={'class': 'checkbox'}),
|
||||
}
|
||||
|
||||
|
||||
from django.forms import modelformset_factory
|
||||
|
||||
# A simplified form used in the bulk edit table (only a few editable fields)
|
||||
class DinosaurBulkForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Dinosaur
|
||||
fields = ['name', 'background', 'speed', 'weight', 'height', 'intelligence']
|
||||
widgets = {
|
||||
'name': forms.TextInput(attrs={'class': 'input'}),
|
||||
'background': forms.Select(attrs={'class': 'input'}),
|
||||
'speed': forms.NumberInput(attrs={'class': 'input', 'min': 0}),
|
||||
'weight': forms.NumberInput(attrs={'class': 'input', 'min': 0}),
|
||||
'height': forms.NumberInput(attrs={'class': 'input', 'step': '0.1'}),
|
||||
'intelligence': forms.NumberInput(attrs={'class': 'input', 'min': 0, 'max': 100}),
|
||||
}
|
||||
|
||||
DinosaurBulkFormSet = modelformset_factory(Dinosaur, form=DinosaurBulkForm, extra=0)
|
||||
|
||||
Reference in New Issue
Block a user