Django with Apache messing up with my settings.py
I'm having a tough problem with Apache messing-up with my settings and urls. Does anyone have any idea of what I'm doing wrong? Question: can I have different 'settings.py' for each Django app running in Apache? As far as I could understand Django docs it should be possible, but... Here's what's happening: I have 2 Django applications configured: app_1 and app_2. Both of them indidvidually work. However they respective urls.py get messed-up if I switch from one app to the other. Here's the strange behavior: 1. I restart Apache 2. I point my browser to app1/index: everything is OK 3. I point my browser to app2/index: I get an error telling me that the requested URL does not. Then the error page tells me that Django tried to use 'app_1.urls', while I was expecting Django would use 'app_2.urls' instead. If I repeat the above steps trying access, at first, app2/index, I get the same strange behavior. But, this time, app1 fails because 'app_2.urls' is used instead of 'app_1.urls', It seems to me that Apache statically loads 'urls.py' the very first time and it is unique for both apps, even if different urlconf are defined within each module. In fact, each 'settings.py' I properly set the ROOT_ULRCONF to point to the proper urlconf. Here's the structure of my directories: /var/www/ myapps/ __init__.py app_1/ settings.py (ROOT_URLCONF = 'app_1.urls') urls.py __init__.py app_2/ settings.py (ROOT_URLCONF = 'app_2.urls') urls.py __init__.py And here's how I defined the apps in Apache2 (running with lastest Django SVN). SetHandler python-program PythonPath "['/var/www/myapps'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE app_1.settings PythonDebug on SetHandler python-program PythonPath "['/var/www/myapps'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE app_2.settings PythonDebug on --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django with Apache messing up with my settings.py
On Mon, 2008-08-25 at 23:45 -0700, mario wrote: [...] > And here's how I defined the apps in Apache2 (running with lastest > Django SVN). > > > SetHandler python-program > PythonPath "['/var/www/myapps'] + sys.path" > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE app_1.settings > PythonDebug on > > > > SetHandler python-program > PythonPath "['/var/www/myapps'] + sys.path" > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE app_2.settings > PythonDebug on > You need to use the PythonInterpreter directive when you have more than one site installed. See http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#multiple-django-installations-on-the-same-apache for details. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django with Apache messing up with my settings.py
On Aug 26, 5:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-08-25 at 23:45 -0700, mario wrote: > > [...] > > > > > And here's how I defined the apps in Apache2 (running with lastest > > Django SVN). > > > > > SetHandler python-program > > PythonPath "['/var/www/myapps'] + sys.path" > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE app_1.settings > > PythonDebug on > > > > > > > SetHandler python-program > > PythonPath "['/var/www/myapps'] + sys.path" > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE app_2.settings > > PythonDebug on > > > > You need to use the PythonInterpreter directive when you have more than > one site installed. > Seehttp://docs.djangoproject.com/en/dev/howto/deployment/modpython/#mult...for > details. For the case where both are inside of the same virtual host then yes. This is because interpreter context for mod_python defaults to the virtual host. Also be aware that if hosting them in the same virtual host, you may need to ensure that SESSION_COOKIE_NAME is set differently for each application if using sessions. This may not be the case if version of Django being used has change described in: http://code.djangoproject.com/ticket/4724 In that case can set SESSION_COOKIE_PATH instead and leave session cookie name the same. Thinking about this, with SCRIPT_NAME changes made for better WSGI compatibility, maybe SESSION_COOKIE_PATH should have defaulted to value of SCRIPT_NAME, or at the least if it was set to None that it took the value of SCRIPT_NAME. Anyway, if you don't ensure each application uses separate cookie name or cookie path context and they have different user database, they can interfere with each other, for example if using admin screens in both. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django with Apache messing up with my settings.py
Malcom, Thank you very much. It solved my problem! On Aug 26, 9:07 am, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Mon, 2008-08-25 at 23:45 -0700, mario wrote: > > [...] > > > > > And here's how I defined the apps in Apache2 (running with lastest > > Django SVN). > > > > > SetHandler python-program > > PythonPath "['/var/www/myapps'] + sys.path" > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE app_1.settings > > PythonDebug on > > > > > > > SetHandler python-program > > PythonPath "['/var/www/myapps'] + sys.path" > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE app_2.settings > > PythonDebug on > > > > You need to use the PythonInterpreter directive when you have more than > one site installed. > Seehttp://docs.djangoproject.com/en/dev/howto/deployment/modpython/#mult...for > details. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django with Apache messing up with my settings.py
Graham, Thank you for your help. II'll pay attention to cookies to. Using the PythonInterpreted directive, as Malcom suggested, solved my problem. On Aug 26, 9:44 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Aug 26, 5:07 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> > wrote: > > > > > On Mon, 2008-08-25 at 23:45 -0700, mario wrote: > > > [...] > > > > And here's how I defined the apps in Apache2 (running with lastest > > > Django SVN). > > > > > > > SetHandler python-program > > > PythonPath "['/var/www/myapps'] + sys.path" > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE app_1.settings > > > PythonDebug on > > > > > > > > > > SetHandler python-program > > > PythonPath "['/var/www/myapps'] + sys.path" > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE app_2.settings > > > PythonDebug on > > > > > > You need to use the PythonInterpreter directive when you have more than > > one site installed. > > Seehttp://docs.djangoproject.com/en/dev/howto/deployment/modpython/#mult...details. > > For the case where both are inside of the same virtual host then yes. > This is because interpreter context for mod_python defaults to the > virtual host. > > Also be aware that if hosting them in the same virtual host, you may > need to ensure that SESSION_COOKIE_NAME is set differently for each > application if using sessions. This may not be the case if version of > Django being used has change described in: > > http://code.djangoproject.com/ticket/4724 > > In that case can set SESSION_COOKIE_PATH instead and leave session > cookie name the same. > > Thinking about this, with SCRIPT_NAME changes made for better WSGI > compatibility, maybe SESSION_COOKIE_PATH should have defaulted to > value of SCRIPT_NAME, or at the least if it was set to None that it > took the value of SCRIPT_NAME. > > Anyway, if you don't ensure each application uses separate cookie name > or cookie path context and they have different user database, they can > interfere with each other, for example if using admin screens in both. > > Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---