Created
March 1, 2022 12:46
-
-
Save okanyenigun/83f8c72d1b3856fad1533b8dbbb87f3c to your computer and use it in GitHub Desktop.
djangologin-forms
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
from django.contrib.auth.forms import UserCreationForm | |
from django.contrib.auth.models import User | |
from django import forms | |
class UserForm(UserCreationForm): | |
username = forms.CharField(widget=forms.TextInput( | |
attrs={ | |
'type': 'username', | |
'placeholder':('Username') | |
} | |
)) | |
first_name = forms.CharField(widget=forms.TextInput( | |
attrs={ | |
'type': 'first_name', | |
'placeholder':('First Name') | |
} | |
)) | |
last_name = forms.CharField(widget=forms.TextInput( | |
attrs={ | |
'type':'last_name', | |
'placeholder':('Last Name') | |
} | |
)) | |
email = forms.EmailField(widget=forms.TextInput( | |
attrs={ | |
'type':'email', | |
'placeholder':('Email') | |
} | |
)) | |
password1 = forms.CharField(max_length=16,widget=forms.PasswordInput( | |
attrs={ | |
# 'class':'form-control', | |
'placeholder':'Password' | |
} | |
)) | |
password2 = forms.CharField(max_length=16,widget=forms.PasswordInput( | |
attrs={ | |
# 'class':'form-control', | |
'placeholder':'Repeat Password' | |
} | |
)) | |
group_choices = ( | |
('M','Manager'), | |
('U','User'), | |
('C','Customer'), | |
) | |
groups = forms.ChoiceField(choices=group_choices) | |
class Meta: | |
model = User | |
fields = ['username','email','first_name','last_name','password1','password2','groups'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment