Fix register url

This commit is contained in:
Kacper Donat 2020-06-08 23:50:26 +02:00
parent d1de7715d7
commit 204d7bf1c5
2 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,7 @@
{% endblock breadcrumbs %}
{% block content %}
<form method="post" action="{% url 'login' %}">
<form method="post" action="{% url 'register' %}">
{% csrf_token %}
{% bootstrap_form form %}

View File

@ -2,6 +2,7 @@ from django.shortcuts import render, get_object_or_404, redirect, reverse
from .models import Album, Photo
from .forms import PhotoForm, AlbumForm
from django.contrib.auth.forms import UserCreationForm as RegisterForm
from django.contrib.auth import login
from django.core.exceptions import PermissionDenied
from django.views.decorators.http import require_http_methods
from django.views.decorators.csrf import csrf_exempt
@ -11,10 +12,12 @@ from app.forms import PhotoEditForm
def register(request):
if request.method == "POST":
form = RegisterForm(request.POST)
if form.is_valid():
form.save()
return redirect("/")
login(request, form.instance)
return redirect(reverse("index"))
else:
form = RegisterForm()