registration page
This commit is contained in:
BIN
accounts/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/admin.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/admin.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/apps.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/apps.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/forms.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/forms.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/models.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/models.cpython-38.pyc
Normal file
Binary file not shown.
BIN
accounts/__pycache__/views.cpython-38.pyc
Normal file
BIN
accounts/__pycache__/views.cpython-38.pyc
Normal file
Binary file not shown.
@@ -1,6 +1,49 @@
|
||||
from django.contrib.auth.forms import AuthenticationForm
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class RegisterForm(UserCreationForm):
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ['username', 'password1', 'password2']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(RegisterForm, self).__init__(*args, **kwargs)
|
||||
self.fields['username'] = forms.CharField(
|
||||
widget=forms.TextInput(attrs={
|
||||
'placeholder': 'Nazwa użytkownika'
|
||||
}),
|
||||
error_messages={
|
||||
'required': 'Wpisz nazwę użytkownika',
|
||||
})
|
||||
self.fields['password1'] = forms.CharField(
|
||||
widget=forms.PasswordInput(attrs={
|
||||
'placeholder': 'Hasło'
|
||||
}),
|
||||
error_messages={
|
||||
'required': 'Podaj hasło',
|
||||
})
|
||||
self.fields['password2'] = forms.CharField(
|
||||
widget=forms.PasswordInput(attrs={
|
||||
'placeholder': 'Powtórz hasło'
|
||||
}),
|
||||
error_messages={
|
||||
'required': 'Podaj hasło',
|
||||
})
|
||||
|
||||
for field in ['username', 'password1', 'password2']:
|
||||
self.fields[field].help_text = None
|
||||
self.fields[field].label = ''
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# class LoginForm(AuthenticationForm):
|
||||
# username = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}))
|
||||
# password = forms.CharField(widget=forms.PasswordInput(attrs={'class': 'form-control'}))
|
||||
|
||||
BIN
accounts/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
BIN
accounts/migrations/__pycache__/__init__.cpython-38.pyc
Normal file
Binary file not shown.
@@ -1,3 +1,13 @@
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from .forms import RegisterForm
|
||||
|
||||
# Create your views here.
|
||||
|
||||
def register(response):
|
||||
if response.method == "POST":
|
||||
form = RegisterForm(response.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return redirect("/")
|
||||
else:
|
||||
form = RegisterForm()
|
||||
return render(response, "registration/signup.html", {"form":form})
|
||||
|
||||
Reference in New Issue
Block a user