Search code examples
pythondjangodjango-viewsdjango-templatesdjango-url-reverse

Django error: Reverse for '...' not found. '...' is not a valid view function or pattern name


It gives the error: Reverse for 'login' not found. 'login' is not a valid view function or pattern name.

urls.py:

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('App.urls')),
    path('accounts/', include(('django.contrib.auth.urls', 'django.contrib.auth'), namespace='login')),
    path('accounts/', include('Account.urls')),
] 

index.html:

<a href="{% url 'login' %}"><h3 class="agileinfo_sign">Sign In </h3></a>

Solution

  • Use this:

    <a href="{% url 'login:login' %}"><h3 class="agileinfo_sign">Sign In </h3></a>
    
    

    Hope this small change will solve your problem.