added user management system
This commit is contained in:
parent
0b31a83f83
commit
8e855e0748
16 changed files with 446 additions and 3 deletions
|
|
@ -1,3 +1,27 @@
|
|||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth import authenticate, login
|
||||
|
||||
# Create your views here.
|
||||
from .forms import SignUpForm
|
||||
|
||||
|
||||
def index(request):
|
||||
return render(request, 'user_manager/index.html')
|
||||
|
||||
|
||||
def register(request):
|
||||
if request.method == 'POST':
|
||||
form = SignUpForm(request.POST)
|
||||
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
username = form.cleaned_data['username']
|
||||
password = form.cleaned_data['password1']
|
||||
user = authenticate(username=username, password=password)
|
||||
login(request, user)
|
||||
return redirect('index')
|
||||
|
||||
else:
|
||||
form = SignUpForm()
|
||||
|
||||
context = {'form': form}
|
||||
return render(request, 'registration/register.html', context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue