Django Crispy form set model field as required
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Forest of Spells Looping
--
Chapters
00:00 Django Crispy Form Set Model Field As Required
00:37 Accepted Answer Score 7
00:54 Thank you
--
Full question
https://stackoverflow.com/questions/4714...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #djangoforms #djangocrispyforms
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Forest of Spells Looping
--
Chapters
00:00 Django Crispy Form Set Model Field As Required
00:37 Accepted Answer Score 7
00:54 Thank you
--
Full question
https://stackoverflow.com/questions/4714...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #djangoforms #djangocrispyforms
#avk47
ACCEPTED ANSWER
Score 7
You can alter self.fields['email'] in the __init__ method. You need to call super() first.
class RegisterMyBuisinessForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
...
super(RegisterMyBuisinessForm, self).__init__(*args, **kwargs)
self.fields['email'].required = True
...