I'm running through a basic project using Django 1.8 and I'm not sure if I am missing something in the documentation or have just misunderstood it.
I am having a problem with urls.py recognizing the correct url patterns.
I am using This section of the Django documentation for examples.
My project directory structure is:
integrations
|--integrations
|--- migrations
|-- ....
|-- __init__.py
|-- admin.py
|-- models.py
|-- settings.py
|-- urls.py
|-- views.py
|-- wsgi.py
|-- templates
|-- ....
|-- manage.py
Specifically, contents of urls.py is:
from django.conf.urls import include, url
from django.contrib import admin
from . import views
urlpatterns = [
url(r'^wsa/', views.index, name='index'),
url(r'^(?P<customer_id>[0-9]+)/$', views.address_detail, name='address_detail'),
url(r'^admin/', include(admin.site.urls)),
]
As you can see, I have wsa listed as a url pattern in this file. Based upon the documentation referred to above, this should be eliminated and instead be url(r'^$', views.index, name='index'),
The documentation also shows a different directory structure with, what appears to be a root urls.py in the root directory alongside manage.py. This is where the documentation indicates I would put my wsa pattern and include in the child urls.py; however when I do so, that file is not read and instead my url patterns begin to fail:
Using the URLconf defined in integrations.urls, Django tried these URL patterns, in this order:
^$ [name='index']
The current URL, wsa/, didn't match any of these.
Corrosponding url.py files that cause failure:
urls.py:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^wsa/', include('integrations.urls')),
url(r'^admin/', include(admin.site.urls)),
]
integrations\urls.py:
from django.conf.urls import include, url
from django.contrib import admin
from . import views
urlpatterns = [
url(r'^$', 'views.index', name='index'),
]
What am I missing?