Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django - split up urls.py into multiple

Tags:

python

django

I know, this is actually basics of django BUT

I tried to split my huge urls.py into 3 pieces. All 3 urls_xxx.py live under one folder: mysite.

then in main urls.py i did:

#urls.py
urlpatterns += patterns('',

    url(r'^', include('urls_search')),
    url(r'^', include('urls_ajax')),
    url(r'^', include('urls_sitemaps')),

)

but it is saying:

ImportError at /
No module named urls_search

this is urls_search.py:

urlpatterns = patterns('myapp.views',
    url(r'^advancedsearch/$', 'advsearch', name="advsearch"),
    url(r'^advancedsearch/tc/$', 'advtcsearch', name="advtcsearch"),
)

my URLCONF:

ROOT_URLCONF = 'mysite.urls'

what am I doing wrong? I am using Django 1.4

like image 868
doniyor Avatar asked Jan 09 '23 17:01

doniyor


1 Answers

remove .py like this:

url(r'^', include('mysite.urls_search')),
like image 107
Hasan Ramezani Avatar answered Jan 19 '23 07:01

Hasan Ramezani