D
D
dert23132020-04-24 12:14:12
Django
dert2313, 2020-04-24 12:14:12

Why does a 404 error appear?

Hello, please help me figure it out, I don’t understand why after logging in it doesn’t go to the home page (index), but a 404 error appears.
If you need something else, please tell me about it.

urls.py users:

from django.urls import path, include

app_name = 'users'
urlpatterns = [
  #включить url авторизации по умолчанию.
  path('', include('django.contrib.auth.urls')),
]

urls.py learning_log
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
  path('admin/', admin.site.urls),
  path('users/', include('users.urls')),
  path('', include('learning_logs.urls')),
  
]


login.html:
{% extends "learning_logs/base.html" %}

{% block content %}

  {% if form.errors %}
    <p>Вы ввели неправильный логин или пароль, попробуйте еще раз.</p>
  {% endif %}

  <form method="post" action="{% url 'users:login'%}">
    {% csrf_token %}
    {{ form.as_p }}

    <button name="submit">Войти</button>
    <input type="hidden" name="next"
      value="{% url 'learning_logs:index' %} /">
  </form>
{% endblock content %}


error itself :
[24/Apr/2020 16:07:01] "GET /users/login/ HTTP/1.1" 200 732
[24/Apr/2020 16:07:03] "POST /users/login/ HTTP/1.1 " 302 0
Not Found: / /
[24/Apr/2020 16:07:03] "GET /%20/ HTTP/1.1" 404 2949
[24/Apr/2020 16:07:13] "GET /users/login / HTTP/1.1" 200 732
[24/Apr/2020 16:07:15] "POST /users/login/ HTTP/1.1" 302 0
Not Found: / /
[24/Apr/2020 16:07:15] " GET /%20/ HTTP/1.1" 404 2949

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill, 2020-04-24
@kustiktm_kirill

Try removing the / at the end in the value field

<input type="hidden" name="next" value="{% url 'learning_logs:index' %} /">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question