Reputation: 2738
I do not understand what is wrong with my Django backend specification
These are my urls
from django.contrib import admin
from django.urls import path,include
from django.conf.urls import url
from store import views
urlpatterns = [
url(r'^', include('store.urls')),
url(r'^accounts', include('registration.backends.default.urls')),
path('admin/', admin.site.urls),
]
This is the tree structure
bookstore
├── bookstore
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ ├── settings.cpython-36.pyc
│ │ ├── urls.cpython-36.pyc
│ │ └── wsgi.cpython-36.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── db.sqlite3
├── manage.py
├── requirements.txt
└── store
├── admin.py
├── apps.py
├── __init__.py
├── migrations
│ ├── 0001_initial.py
│ ├── 0002_auto_20180604_0751.py
│ ├── __init__.py
│ └── __pycache__
│ ├── 0001_initial.cpython-36.pyc
│ ├── 0002_auto_20180604_0751.cpython-36.pyc
│ └── __init__.cpython-36.pyc
├── models.py
├── __pycache__
│ ├── admin.cpython-36.pyc
│ ├── __init__.cpython-36.pyc
│ ├── models.cpython-36.pyc
│ ├── urls.cpython-36.pyc
│ └── views.cpython-36.pyc
├── templates
│ ├── registration
│ │ ├── activate.html
│ │ ├── activation_complete.html
│ │ ├── activation_email_subject.txt
│ │ ├── activation_mail.txt
│ │ ├── registration_complete.html
│ │ └── registration_form.html
│ ├── store.html
│ └── template.html
├── tests.py
├── urls.py
└── views.py
Now when I try
python manage.py runserver
I got this
Also in terminal shows me
Not Found: /accounts
[05/Jun/2018 09:08:17] "GET /accounts HTTP/1.1" 404 5632
If I go for
url(r'^accounts/', include('registration.backends.default.urls')),
then I have
1. ^accounts/
....
The current path, accounts, didn't match any of these.
How to fix this? How does Django backend work? I am using 2.0.5 version.
Upvotes: 0
Views: 192
Reputation: 6351
Use path
instead of url
:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('', include('store.urls')),
path('accounts/', include('registration.backends.default.urls')),
path('admin/', admin.site.urls),
]
By the way, if Django version <= 1.11, use url
. (path
was added after 2.0)
Upvotes: 1
Reputation: 21
Try using
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^/', include('store.urls')),
Rather than
url(r'^accounts', include('registration.backends.default.urls')),
url(r'^', include('store.urls')),
Upvotes: 0