I have created a new Django project and added a couple of packages, including the django-allauth package. In my urls.py I have the following:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('ckeditor5/', include('django_ckeditor_5.urls')),
path('accounts/', include('allauth.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Now when I start runserver, it says
Starting development server at http://127.0.0.1:8000/
If I go to http://127.0.0.1:8000/admin/, everything is fine and I do get the login form. But if I go to http://127.0.0.1:8000/accounts/login/, I get redirected to http://127.0.0.1:8000/accounts/profile/ with the following error:
Page not found (404)
Request Method: GET Request URL: http://127.0.0.1:8000/accounts/profile/ Using the URLconf defined in
elearning.urls
, Django tried these URL patterns, in this order:
- admin/
- ckeditor5/
- accounts/ signup/ [name=‘account_signup’]
- accounts/ login/ [name=‘account_login’]
- accounts/ logout/ [name=‘account_logout’]
- accounts/ password/change/ [name=‘account_change_password’]
- accounts/ password/set/ [name=‘account_set_password’]
- accounts/ inactive/ [name=‘account_inactive’]
- accounts/ email/ [name=‘account_email’]
- accounts/ confirm-email/ [name=‘account_email_verification_sent’]
- accounts/ ^confirm-email/(?P[-:\w]+)/$ [name=‘account_confirm_email’]
- accounts/ password/reset/ [name=‘account_reset_password’]
- accounts/ password/reset/done/ [name=‘account_reset_password_done’]
- accounts/ ^password/reset/key/(?P[0-9A-Za-z]+)-(?P.+)/$ [name=‘account_reset_password_from_key’]
- accounts/ password/reset/key/done/ [name=‘account_reset_password_from_key_done’]
- accounts/ social/
- accounts/ google/
- ^media/(?P.*)$
The current path,
accounts/profile/
, didn’t match any of these.You’re seeing this error because you have
DEBUG = True
in your Django settings file. Change that toFalse
, and Django will display a standard 404 page.
However the http://localhost:8000/accounts/login/ path works fine and I see the authentication page. Why is it that 127.0.0.1:8000
doesn’t work while localhost:8000
does? Thank you for your help!