URL configuration with Django deployed in a subdirectory

382 views
Skip to first unread message

bryanzera

unread,
Aug 29, 2008, 3:40:17 PM8/29/08
to Django users
I am a new Django user with Django 0.96 deployed in a sub-directory
under our main document root. My problem is that I cannot get my URL
configuration to work.

Inside the Django-deployed subdirectory, I have the following urls.py
file:
<blockquote>
from django.conf.urls.defaults import *

base_url = 'columbia_django/'

urlpatterns = patterns('',
(r'^' + base_url + 'hr/', include('columbia_django.hr.urls')),
)
</blockquote>

Inside the 'hr/' sub-directory, I have the following urls.py file:
<blockquote>
from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^$', 'columbia_django.hr.views.index'),
(r'^job/(?P<job_id>\d+)/$', 'columbia_django.hr.views.view_job'),
(r'^by_department/$', 'columbia_django.hr.views.by_department'),
(r'^search/$', 'columbia_django.hr.views.search'),
(r'^admin/', include('django.contrib.admin.urls')),
(r'^test/$', 'columbia_django.hr.views.test'),
)
</blockquote>

When I go to http://myserver/columbia_django/hr, the index view is
displayed, but none of the other URLs in the hr/urls.py work.

I would use the django.root parameter in the httpd.conf file, but 0.96
doesn't support this.

Any help is greatly appreciated.

Erik Allik

unread,
Aug 29, 2008, 4:17:06 PM8/29/08
to django...@googlegroups.com
Just to let you know, if you upgraded your Django version, you
wouldn't have to manually specify base_url in you URLconf because
Django will do it for you. I'm not sure what's causing your problem
though.

Erik

Graham Dumpleton

unread,
Aug 30, 2008, 1:06:16 AM8/30/08
to Django users
> When I go tohttp://myserver/columbia_django/hr, the index view is
> displayed, but none of the other URLs in the hr/urls.py work.
>
> I would use the django.root parameter in the httpd.conf file, but 0.96
> doesn't support this.
>
> Any help is greatly appreciated.

You don't say how you are deploying the site.

If you were using mod_wsgi it explains in the documentation for
hooking up Django what you need to do to get mounting at a sub URL to
work. See:

http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

Graham

bryanzera

unread,
Sep 2, 2008, 11:52:28 AM9/2/08
to Django users
> You don't say how you are deploying the site.

mod_python/apache2

bryanzera

unread,
Sep 2, 2008, 12:03:34 PM9/2/08
to Django users
I've figured it out.

.htaccess above my subdirectory was trying to munge my URLs rather
than letting Django take care of them.
Reply all
Reply to author
Forward
0 new messages