25 lines
600 B
Python
25 lines
600 B
Python
from django import forms
|
|
|
|
from .models import Thing
|
|
|
|
|
|
class ThingForm(forms.ModelForm):
|
|
"""Form for adding a Thing."""
|
|
|
|
class Meta:
|
|
model = Thing
|
|
fields = ('name', 'thing_type', 'description', 'picture')
|
|
widgets = {
|
|
'name': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'thing_type': forms.Select(attrs={'class': 'form-control'}),
|
|
'description': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
|
|
}
|
|
|
|
|
|
ThingFormSet = forms.modelformset_factory(
|
|
Thing,
|
|
form=ThingForm,
|
|
extra=1,
|
|
can_delete=False
|
|
)
|