Нормальные страницы входа и выхода
This commit is contained in:
@@ -5,4 +5,4 @@ from django.shortcuts import get_object_or_404, redirect, render
|
||||
def custom_logout(request):
|
||||
"""Разлогиниться и перейти на главную."""
|
||||
logout(request)
|
||||
return redirect("books:book_list")
|
||||
return redirect("books:logout")
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
<!-- templates/accounts/login.html -->
|
||||
{% extends 'books/base.html' %}
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Вход</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Вход</h1>
|
||||
|
||||
{% block content %}
|
||||
<h2>Вход</h2>
|
||||
<form method="post" action="">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit">Войти</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Выход</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Вы вышли из аккаунта</h1>
|
||||
<a href="{% url 'books:book_list' %}">На главную</a>
|
||||
</body>
|
||||
</html>
|
||||
<!-- templates/accounts/logout.html -->
|
||||
{% extends 'books/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Вы вышли из аккаунта</h2>
|
||||
<p><a href="{% url 'books:book_list' %}">Вернуться на главную</a></p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{% for genre in genres %}
|
||||
<li>
|
||||
{{ genre.name }}
|
||||
<a href="{% url 'books:genre_recommendations' genre.name %}">Перейти к книгам</a>
|
||||
<a href="{% url 'books:genre_recommendations' genre.name %}">Перейти к рекомендациям</a>
|
||||
<!-- ссылки на редактирование/удаление жанра -->
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'books:edit_genre' genre.pk %}">Редактировать</a>
|
||||
|
||||
@@ -22,4 +22,5 @@ urlpatterns = [
|
||||
name="genre_recommendations",
|
||||
),
|
||||
path("register/", views.register, name="register"),
|
||||
path("succesful-logout/", views.logout, name="logout"),
|
||||
]
|
||||
|
||||
@@ -21,6 +21,10 @@ def register(request):
|
||||
return render(request, "accounts/register.html", {"form": form})
|
||||
|
||||
|
||||
def logout(requst):
|
||||
return render(requst, "accounts/logout.html")
|
||||
|
||||
|
||||
def book_list(request):
|
||||
"""Главная страница со списком всех книг."""
|
||||
books = Book.objects.all()
|
||||
|
||||
Reference in New Issue
Block a user