Created
October 20, 2021 00:50
-
-
Save Marceloromeugoncalves/5d03bc853ddd878fcd45129cad4211d9 to your computer and use it in GitHub Desktop.
Exemplo - Estendendo o UserCreationForm do Django.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#forms.py | |
from django import forms | |
from django.contrib.auth.models import User | |
from django.contrib.auth.forms import UserCreationForm | |
from .models import Profile | |
class UserRegisterForm(UserCreationForm): | |
email = forms.EmailField() | |
class Meta: | |
model = User | |
fields = ['username', 'email', 'password1', 'password2'] | |
class UserUpdateForm(forms.ModelForm): | |
email = forms.EmailField() | |
class Meta: | |
model = User | |
fields = ['username', 'email'] | |
class ProfileUpdateForm(forms.ModelForm): | |
class Meta: | |
model = Profile | |
fields = ['image'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
password1 = password
password2 = confirmação do password