Skip to content

Instantly share code, notes, and snippets.

@okanyenigun
Created March 1, 2022 12:46
Show Gist options
  • Save okanyenigun/83f8c72d1b3856fad1533b8dbbb87f3c to your computer and use it in GitHub Desktop.
Save okanyenigun/83f8c72d1b3856fad1533b8dbbb87f3c to your computer and use it in GitHub Desktop.
djangologin-forms
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