12👍
Form fields don’t have null
or blank
arguments. Those are for model fields only. For form fields, you just have required
.
However, you should really be using a ModelForm which will create the form fields for you from the model, and allow you to save it afterwards.
1👍
Not positive, but I don’t think you can use null=True
or blank=True
on a forms.CharField()
, you are passing null as a parameter to the init() of the forms.CharField
and the interpreter is throwing this error. Try removing null=True
from:
Change your forms to:
class UserForm(forms.Form ):
fname=forms.CharField(max_length=20)
lname=forms.CharField(max_length=20)
email = forms.EmailField()
address = forms.CharField(max_length=50)
country = forms.CharField(max_length=20)
Per the django site Django Form Fields, CharField has two optional arguments for validation: max_length and min_length, along with required.
- [Django]-Creating SubCategories with Django Models
- [Django]-Django-allauth adapter redirects
- [Django]-Django MultipleObjectsReturned
- [Django]-PHP and Django: Nginx, FastCGI and Green Unicorn?
Source:stackexchange.com