22๐
You should be able subclass the provided registration form and override properties of a field in the Meta
class.
from django.contrib.auth.forms import UserCreationForm
# Not sure about the syntax on this one. Can't find the documentation.
class MyUserCreationForm(UserCreationForm):
class Meta:
email = {
'required': True
}
# This will definitely work
class MyUserCreationForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(MyUserCreationForm, self).__init__(*args, **kwargs)
self.fields['email'].required = True
๐คDerek Reynolds
7๐
from django import forms
from django.contrib.auth.models import User
class MyUserForm(forms.ModelForm):
email = forms.CharField(max_length=75, required=True)
class Meta:
model = User
fields = ('username', 'email', 'password')
๐คDmitry
- ASGI_APPLICATION not working with Django Channels
- Django reset_password_confirm TemplateSyntaxError problem
- How do I select from multiple tables in one query with Django?
- Django test database is not created with utf8
- How do I construct a Django form with model objects in a Select widget?
0๐
use EmailField
in your model
see more at
https://docs.djangoproject.com/en/2.1/ref/models/fields/#emailfield
- Django Inner Join Queryset
- Libmysqlclient.18.dylib image not found when using MySQL from Django on OS X
- Django Queryset of related objects, after prefiltering on original model
- 'QuerySet' object has no attribute ERROR, trying to get related data on ManyToMany fields
- Decorators run before function it is decorating is called?
Source:stackexchange.com