non-root URL django installation

215 views
Skip to first unread message

sebhaase

unread,
Dec 29, 2007, 4:40:16 PM12/29/07
to Django users
Hi,
I have developped a small django app and I like it a lot.
I have tested it on a local setup using "manage.py runserver" on a
custom port.

Now I wanted to move this to our apache2 based web site and got my sys
admin convinced to install mod_python and I got a httpd.conf like
this:
<Location /subDir/djangoApp>
..... django settings .....
</Location>

Problem of course now is that all django request URLs now start with
/subDir/djangoApp

What should I do ?


So far I have messed with urls.py. But that looks ugly !

Is it possible to get the "/subDir/djangoApp" prefix removed from the
URL before the rest of django handles the URLs !?

The idea would be along the lines of a what the moinmoin Wiki calls a
non-root moinmoin installation; read this:
http://moinmo.in/HelpOnInstalling/ApacheWithModPython#head-2dba68d0d0ad069f1c4a2a46bcdbd07cb21d3887
(http://moinmo.in/HelpOnInstalling/ApacheWithModPython --> Solving
problems for non-root-mounted wikis )
They use a special
PythonOption Location .....
httpd.conf line.

Thanks for any help.
Sebastian Haase

hedronist

unread,
Dec 29, 2007, 5:34:34 PM12/29/07
to Django users

> Is it possible to get the "/subDir/djangoApp" prefix removed from the
> URL before the rest of django handles the URLs !?

Yes, at least I think you can. (Note: I haven't actually tested this,
and it feels a bit kludgey, but it's where I would start.)

In http://www.djangoproject.com/documentation/url_dispatch/, look for
the section titled: Including other URLconfs. In the included conf
file, all of the patterns are applied against *the unmatched tail* of
the requested URL. So, in your top-level urls.py file you could have:

urlpatterns = patterns('',
(r'^subDir/djangoApp', include('app_dir_name')),
)
Note: No trailing / and no $ -- this is a head match.

The urls.py in app_dir_name you have your real urls.py. Something like
that. It would be easier if they just created a subdomain for you and
then setup an Apache Virtual Host. Then everything is normal.

hedronist

unread,
Jan 1, 2008, 1:22:42 PM1/1/08
to Django users
Er, correction, you *do* want the trailing /.

> urlpatterns = patterns('',
> (r'^subDir/djangoApp/', include('app_dir_name')),
> )
> Note: No $ -- this is a head match.
Reply all
Reply to author
Forward
0 new messages