Ошибка Using the URLconf defined in webloop.urls, Django tried these URL patterns, in this order:

В проекте Django есть функция которая позволяет пользователю авторизоваться на сайт, это не отдельный шаблон а модельное окно, которое вызывается путем нажатия на кнопку "Вход"

введите сюда описание изображения

Но при вводе логина и пароля выходит следующая ошибка:

введите сюда описание изображения

Я добавил в код

def get_success_url(self):
        return reverse_lazy('registration')

Но ошибка по прежнему осталась.

views.py code:

class LoginUser(LoginView):
    form_class = AuthenticationForm
    template_name = 'main/doki.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        c_def = self.get_user_context(title='Авторизация')
        return dict(list(context.items()) + list(c_def.items()))

    def get_success_url(self):
        return reverse_lazy('registration')

urls.py code:

from django.urls import path
from .import views

urlpatterns = [
    path('doki/', views.LoginUser.as_view(), name='login')
]

HTML code:

{% load static %}
<!DOCTYPE html>
<html lang="ru">
<head>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css">
    <script src="https://unpkg.com/@popperjs/core@2/dist/umd/popper.js"></script>
    <script src="https://unpkg.com/@popperjs/core@2"></script>
    <link rel="stylesheet" href="{% static 'main/CSS/main.css/'%}">
    <meata charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="shortcut icon" href="http://vladmaxi.net/favicon.ico" type="image/x-icon">
    <title>{% block websystems %}{% endblock %}</title>
</head>
<body>
    <aside>

        <script>
            var modal = document.getElementById('id01');

            window.onclick = function(event) {
                if (event.target == modal) {
                    modal.style.display = "none";
                }
            }
        </script>

        <img src="{% static 'main/img/logo.png'%}" alt="">
        <span class="logo">WebSystems</span>
        <h3>Навигация</h3>
        <ul>
            <a href="{% url 'home' %}"><li><i class="fas fa-home"></i> Главная</li></a>
            <a href="{% url 'group' %}"><li><i class="far fa-object-group"></i> Группы</li></a>
            <a href="{% url 'students' %}"><li><i class="fas fa-users"></i> Студенты</li></a>
            <a href="{% url 'info_home' %}"><li><i class="fas fa-info"></i> Кол-во студентов и групп</li></a>
        </ul>

<button onclick="document.getElementById('id01').style.display='block'">Вход</button>
<div id="id01" class="modal">
  <span onclick="document.getElementById('id01').style.display='none'" 
    class="close" title="Close Modal">&times;</span>

    <form class="modal-content animate" action="/action_page.php">
        <div class="imgcontainer">
        </div>

        <div class="container">
            <label for="uname"><b>Username</b></label>
            <input type="text" placeholder="Логин" name="uname" required>

            <label for="psw"><b>Password</b></label>
            <input type="password" placeholder="Пароль" name="psw" required>

            <button type="submit">Войти</button>
            <label>
                <input type="checkbox" checked="checked" name="remember"> Запомнить данные входа
            </label>
        </div>

        <div class="container" style="background-color:#f1f1f1">
            <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Отмена</button>
        </div>
    </form>
</div>

<style>
    .modal {
        display: none; /* Hidden by default */
        position: fixed; /* Stay in place */
        z-index: 1; /* Sit on top */
        left: 0;
        top: 0;
        width: 100%; /* Full width */
        height: 100%; /* Full height */
        overflow: auto; /* Enable scroll if needed */
        background-color: rgb(0,0,0); /* Fallback color */
        background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
        padding-top: 60px;
    }

    /* Modal Content/Box */
    .modal-content {
        background-color: #fefefe;
        margin: 5px auto; /* 15% from the top and centered */
        border: 1px solid #888;
        width: 80%; /* Could be more or less, depending on screen size */
    }

    /* The Close Button */
    .close {
        /* Position it in the top right corner outside of the modal */
        position: absolute;
        right: 25px;
        top: 0; 
        color: #000;
        font-size: 35px;
        font-weight: bold;
    }

    /* Close button on hover */
    .close:hover,
    .close:focus {
        color: red;
        cursor: pointer;
    }

    /* Add Zoom Animation */
    .animate {
        -webkit-animation: animatezoom 0.6s;
        animation: animatezoom 0.6s
    }

    @-webkit-keyframes animatezoom {
        from {-webkit-transform: scale(0)} 
        to {-webkit-transform: scale(1)}
    }

    @keyframes animatezoom {
        from {transform: scale(0)} 
        to {transform: scale(1)}
    }

    form {
    border: 3px solid #f1f1f1;
    }

    /* Full-width inputs */
    input[type=text], input[type=password] {
        width: 100%;
        padding: 12px 20px;
        margin: 8px 0;
        display: inline-block;
        border: 1px solid #ccc;
        box-sizing: border-box;
    }

    /* Set a style for all buttons */
    button {
        background-color: #4CAF50;
        color: white;
        padding: 14px 20px;
        margin: 8px 0;
        border: none;
        cursor: pointer;
        width: 100%;
    }

    /* Add a hover effect for buttons */
    button:hover {
        opacity: 0.8;
    }

    /* Extra style for the cancel button (red) */
    .cancelbtn {
        width: auto;
        padding: 10px 18px;
        background-color: #f44336;
    }

    /* Center the avatar image inside this container */
    .imgcontainer {
        text-align: center;
        margin: 24px 0 12px 0;
    }

    /* Avatar image */
    img.avatar {
        width: 40%;
        border-radius: 50%;
    }

    /* Add padding to containers */
    .container {
        padding: 16px;
    }

    /* The "Forgot password" text */
    span.psw {
        float: right;
        padding-top: 16px;
    }

    /* Change styles for span and cancel button on extra small screens */
    @media screen and (max-width: 300px) {
        span.psw {
            display: block;
            float: none;
        }
        .cancelbtn {
            width: 100%;
        }
}
</style>

    </aside>
    <main>
        {% block content %}
        {% endblock %}
    </main>
</body>
</html>

Вернуться на верх