11👍
Here a solution to make a field required :
class Foo(CreateView):
model = Fiz
fields = ('bar',)
def get_form(self, form_class=None):
form = super(Foo, self).get_form(form_class)
form.fields['bar'].required = True
return form
0👍
i think no but you can implement in it !
class ModelXForm(ModelForm):
class Meta:
model = x
fields = ['image','name']
def __init__(self,update, survey, **kwargs):
super(FBRequestForm, self).__init__(**kwargs)
if not update:
self.fields['image'].widget.attrs['readonly'] = True
self.fields['image'].widget = forms.HiddenInput()
- [Django]-Unable to understand a line from the django tutorial
- [Django]-Non_field_errors : ["Expected a list of items but got type "dict"."]
Source:stackexchange.com