0

When i am pressing the login button I am getting 404 error even though it is rendered to same page. The Error is :-

Using the URLconf defined in AmazeKart.urls, Django tried these URL patterns, in this order:

admin/
register/ [name='register']
login/ [name='login']
The current path, login/login, didn’t match any of these.

Views.py:-

def login(request):
    return render(request, 'login.html')

URLS.py of app

urlpatterns = [
    path('register/', views.registerPage, name='register'),
    path('login/', views.login,name='login')
]

URLS.py of project

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('User.urls'))
]
Ajay D.
  • 1
  • 2
  • Can you show the template that you rendered that has a link? – Willem Van Onsem Jul 28 '21 at 20:21
  • Would the solution in the below question work for you? https://stackoverflow.com/questions/806835/django-redirect-to-previous-page-after-login?rq=1 – Marcus D. Jul 28 '21 at 20:32
  • This is the login template

    LOGIN

    {% csrf_token %}
    {% for message in messages %}

    {{message}}

    {% endfor %}
    {% endblock %}
    – Ajay D. Jul 29 '21 at 03:58

1 Answers1

0

In the settings.py write: LOGIN_REDIRECT_URL = 'login/'

  • Can u specify where should I write it cause I had tried writing it below installed apps list it's not working. – Ajay D. Jul 29 '21 at 04:04
  • It isn't important the row in the settings.py, but this work only if you use the django built-in login view, [https://docs.djangoproject.com/en/3.2/topics/auth/default/](https://docs.djangoproject.com/en/3.2/topics/auth/default/), except you have to return from your view `HttpRedirect(path)`. – Nicolò Teseo Jul 29 '21 at 17:03