How do I solve urlpatterns problem in django?

42 Views Asked by At
from django.conf.urls import url
from django.contrib.auth.views import LoginView
from django.contrib.auth.views import LoginView, LogoutView
from . import views

urlpatterns = [
    url(r'^login/$', LoginView, name='login', kwargs={
        'template_name': 'accounts/login_form.html',
    }),
    url(r'^logout/$', LogoutView, name='logout', kwargs={
        'next_page': 'login',
    }),
    url(r'^signup/$', views.signup, name='signup'),
    url(r'^signup/$', views.signup, name='signup'),
    url(r'^profile/$', views.profile, name='profile'),
]

enter image description here

Hello I've read through other posts regarding this error and I thought I solved the problem, but I'm still having trouble.

2

There are 2 best solutions below

0
Daniel On

Try:

from django.urls import path
from . import views

urlpatterns = [
    path('/my/url', views.MyViewFunction, name='my_url_name'),
]
0
Steven On

There is no url such as accounts/login_form. Perhaps you should go to accounts/login, use name='login'. You should also consider using path('url_here', function, name=name_here) instead of the old url.