b10n1k
b10n1k

Reputation: 615

django urlconf cant find directives to including urls

i read the "practical django projects" and i stack on chapter 5. In general i have done exactly as it is in the book. I created a urls dir in coltrane app, I removed the urls.py file and i edited the urls.py in cms to write the include statements for each coltranes' model. But the server returns with an ImproperlyConfigured type error and a message that says "The included urlconf cms.urls doesn't have any patterns in it". i thought that it should search into coltrane.urls so i set the urlconf to this one. But the output still is the same. here is the code.

Can anyone show me why this is happen or give me some good resources or example to understand how it works???

Upvotes: 0

Views: 64

Answers (1)

jproffitt
jproffitt

Reputation: 6355

Your ROOT_URLCONF is coltrane.urls, which is a python package. Which means the __init__.py will be used. But there is no urlpatterns variable in your __init__.py. If you want to include all the sub-url files you could do something like the following:

import categories
import entries
import links
import tags

urlpatterns = categories.urlpatterns + entries.urlpatterns + links.urlpatterns + tags.urlpatterns

However, I would not necessarily suggest that. Also, coltrane.urls doesn't look like a root url file to me. Maybe cms.urls should be the root. Then in cms.urls you can include coltrane.urls by adding this to your urlpatterns:

(r'', include('coltrane.urls')),

Upvotes: 1

Related Questions