Bonjour,
j'essaie de mettre en place une application d'authentification 'registration' dans mon projet mais j'ai un problème de route que je n'arrive pas à comprendre
sur mon formulaire login, j'ai un lien pour modifier le mot de passe mais la route est erronée mais je ne comprends pas
fichier urls.py de mon application registration :http://localhost:8000/accounts/login...ssword_change/
Using the URLconf defined in acme.urls, Django tried these URL patterns, in this order:
__debug__/
[name='home']
about/ [name='about']
contact/ [name='contact']
blog/
registration/
admin/
The current path, accounts/login/, didn't match any of these.
fichier login.html :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 from django.urls import path from . import views from django.contrib.auth import views as auth_views app_name='registration' urlpatterns = [ path('login', views.login, name='login'), path('logout', views.logout, name='logout'), path('password_change', views.password_change, name='password_change'), ]
Code twig : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 {% extends 'layouts/base.html' %} {% load widget_tweaks %} {% block title %}Homepage | Acme{% endblock %} {% block content %} <div class='container'> <form method="post" class="form-signin"> <!--<h2 class="form-signin-heading">Login</h2>--> {% csrf_token %} {{ form.as_p }} <button type="submit" class="btn btn-lg btn-primary btn-block">Connexion</button> </form> <a class="nav-link text-center" href="{% url 'password_change' %}">Changer mot de passe</a> </div> {% endblock %}
dans le fichier setting.py :
architecture de mon projet :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR,'registration/templates'), os.path.join(BASE_DIR,'templates'), ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ]
![]()
Partager