diff options
Diffstat (limited to 'accounts/views.py')
-rw-r--r-- | accounts/views.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/accounts/views.py b/accounts/views.py index 2616923..4a0d3ed 100644 --- a/accounts/views.py +++ b/accounts/views.py | |||
@@ -1,5 +1,28 @@ | |||
1 | from django.shortcuts import render | 1 | from django.shortcuts import render, redirect |
2 | from django.contrib.auth import authenticate, login | ||
3 | |||
4 | from accounts.forms import UserCreationForm | ||
2 | 5 | ||
3 | 6 | ||
4 | def profile(request): | 7 | def profile(request): |
5 | return render(request, "accounts/profile.html") | 8 | return render(request, "accounts/profile.html") |
9 | |||
10 | |||
11 | def create_account(request): | ||
12 | form = UserCreationForm() | ||
13 | |||
14 | if request.method == "POST": | ||
15 | form = UserCreationForm(request.POST) | ||
16 | |||
17 | if form.is_valid(): | ||
18 | form.save() | ||
19 | |||
20 | user = authenticate(username=form.cleaned_data["username"], | ||
21 | password=form.cleaned_data["password1"]) | ||
22 | login(request, user) | ||
23 | |||
24 | return redirect("account:profile") | ||
25 | |||
26 | return render(request, "accounts/create.html", { | ||
27 | "form": form, | ||
28 | }) | ||