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

killerbees picture killerbees · Jan 19, 2018 · Viewed 11.2k times · Source

I have a problem with Django. Actually I want to create a login panel in my new site but when I try to write address the debugger respond me a error:

Page not found (404)
Request Method: GET
Request URL:    http://localhost:8000/account/login
Using the URLconf defined in firmowa.urls, Django tried these URL patterns, in this order:

admin/
^account/
The current path, account/login, didn't match any of these.

My firmowa.urls is

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

    urlpatterns = [
        path('admin/', admin.site.urls),
        path(r'^account/', include('account.urls')),
    ]

And the project urls.py is:

from django.urls import path
from . import views

urlpatterns = [
    path(r'^login/$', views.user_login, name='login'),
]

I'm looking a solution from few hours but still nothing.

Answer

petr picture petr · Jan 19, 2018

path is a new feature in Django 2.0 and works different than the old url. Don't use regex in path. If you need regex, use re_path instead, but in your case there's no need for that.

Change your code to:

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

etc. and it should work.

More on the topic here and here.