Ankit Jaiswal
Ankit Jaiswal

Reputation: 763

Django-modpython deploying project

I am deploying a Django project on apache server with mod_python in linux. I have created a directory structure like: /var/www/html/django/demoInstall where demoInstall is my project. In the httpd.conf I have put the following code.

<Location "/django/demoInstall">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE demoInstall.settings
    PythonOption django.root django/demoInstall
    PythonDebug On
    PythonPath "['/var/www/html/django'] + sys.path"

</Location>

It is getting me the django environment but the issue is that the urls mentioned in urls.py are not working correctly.

In my url file I have mentioned the url like:

 (r'^$', views.index),

Now, in the browser I am putting the url like : http://domainname/django/demoInstall/ and I am expecting the views.index to be invoked. But I guess it is expecting the url to be only: http://domainname/ .

When I change the url mapping to:

  (r'^django/demoInstall$', views.index),

it works fine. Please suggest as I do not want to change all the mappings in url config file.

Thanks in advance.

Upvotes: 1

Views: 75

Answers (2)

Graham Dumpleton
Graham Dumpleton

Reputation: 58543

That should be:

PythonOption django.root /django/demoInstall

Ie., must match sub URL in Location directive.

You shouldn't be using that prefix in urls.py.

Upvotes: 0

pycruft
pycruft

Reputation: 68765

There's a fairly simple way around this using just django, without having to touch apache.

Rename your urls.py to something else, e.g. site_urls.py

Then create a new urls.py which includes that

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^django/demoInstall/', include('site_urls.py')),
)

This will ensure that all the url reversing continues to work, too.

Upvotes: 2

Related Questions