Re: ubuntu 6.06 deployment issues
Sorry to re-awaken this thread, but it seems that people are still having issues with this PYTHONPATH info. In an attempt to get this sorted out, I've attached a patch to #4296 that adds a bit more info. Can anyone add any more info to what I've got? Thanks, Simon G #4296 - http://code.djangoproject.com/ticket/4296 --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
Graham Dumpleton wrote: > On Jul 6, 2:59 pm, John-Scott <[EMAIL PROTECTED]> wrote: >> On Jul 6, 12:29 am, Graham Dumpleton <[EMAIL PROTECTED]> >> wrote: >> >>> Hmmm, I'm not sure the documentation is actually accurate. When you >>> use manage.py to run up development server for Django, it will >>> automatically add the parent directory of where the manage.py file is >>> located into sys.path for you. Thus, there isn't strictly a need to >>> add it to PYTHONPATH to get it to work in the first place. >>> So, the answer is that YES, for mod_python you must use the PythonPath >>> directive to specify the parent directory of where manage.py is >>> located in order for your settings file to be found correctly. >>> Graham >> Graham - I was suspicious of that. I remember reading that manage.py >> took care of setting all the environment variables for the development >> server and interactive shell. But it didn't seem possible for >> mod_python to have any idea where our projects are implicitly. Should >> we file a doc bug? > > Someone can correct me, but I think it gets a bit more confusing than > that, so there is possibly other changes which should be made to the > mod_python documentation. > > When using manage.py it imports settings.py explicitly, thus there is > no need to define DJANGO_SETTINGS_MODULE like with mod_python to say > what the actual settings module name is. At this point though, only > the directory containing manage.py is effectively in sys.path. This > would mean that where you have in urls.py: > > (r'^mysite1/', include('mysite1.apps.foo.urls.foo')), > > it would actually fail to find the referenced module. > > In searching through Django, the only place it adds the parent > directory to sys.path so that it might find that referenced module is: > > def setup_environ(settings_mod): > """ > Configure the runtime environment. This can also be used by > external > scripts wanting to set up a similar environment to manage.py. > """ > # Add this project to sys.path so that it's importable in the > conventional > # way. For example, if this file (manage.py) lives in a directory > # "myproject", this code would add "/path/to/myproject" to > sys.path. > project_directory = os.path.dirname(settings_mod.__file__) > project_name = os.path.basename(project_directory) > sys.path.append(os.path.join(project_directory, '..')) > project_module = __import__(project_name, {}, {}, ['']) > sys.path.pop() > > If you look carefully, what it does is append the parent directory to > sys.path and imports the name of the site directory itself. This has > the effect of importing the __init__.py in the site directory. It then > removes the parent directory from sys.path. > > Even though it has removed the parent directory from sys.path, the > import of the module referenced in urls.py by the site name still > works because of the presence of the 'mysite1' module in sys.modules. > Ie., Python sees that module, works out from __file__ of the module > where it is located and searches for the submodule relative to that > directory. > > So, importing modules by site package root is okay, but problem is > that the site directory itself is still in sys.path. This means one > can actually do: > > (r'^mysite1/', include('apps.foo.urls.foo')), > > Ie., one can leave out the site name in the module path and it will > still work. > > Some people do imports this way as it means that if you rename the > site you don't have to change the urls.py file. Also, easier to > develop reusable components that you can copy from one project to > another. > > The problem with this is that if an application which uses these > imports without the site name in them is hosted on mod_python, it will > not work. This is because not only do you have to set PythonPath to > include the parent directory of the site, you also have to list the > site directory path itself. Ie., > > PythonPath "['/path/to/parent','/path/to/parent/mysite1'] + > sys.path" "will not work" is alarming, but then you say "also have to..." which makes me think it will work. so only problem is PythonPath having an extra entry, right? I have been developing my site under the impression that whatever works with ./manage.py runserver will work with mod_python without having to touch 'the app' (I expect to have to touch httpd.conf files.) Personally, I am not trilled by some of the search path behavior, but the root of that is native python, and so as long as django's behavior is somewhat consistent with Python's, I will live with it. If there is something that strays too far and is causing problems, I may get fanatical about it. I setup > > I am not sure this is clearly mentioned in the mod_python document for > Django or not. > > Certainly, the need to do this is explained on the mailing list every > so often, so there must be some confusion about it. I setup a mod_python server last week, and it
Re: ubuntu 6.06 deployment issues
Maybe an example would be useful as well: == Apache conf file === ServerName site.com ServerAdmin [EMAIL PROTECTED] DocumentRoot /home/user/django/site SetHandler python-program PythonPath "['/home/user/django'] + sys.path" PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE recruiting_new.settings #PythonDebug On SetHandler None SetHandler None Site_media is a sub-directory in my site directory. Admin_media is a short-cut to the django_src/django/contrib/admin/media directory. The short-cut is also in the site directory. == settings.py file === MEDIA_ROOT = '/home/user/django/site/site_media/' ADMIN_MEDIA_PREFIX = '/admin_media/' Templates: TEMPLATE_DIRS = ( '/home/user/django/site/templates', ) This works for me. Vincent On 7/6/07 12:09 AM, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > > On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote: >> In my settings.py, I now have: >> MEDIA_ROOT = '/var/www/mysite.com/media/' >> MEDIA_URL = 'http://mysite.com/media/' >> ADMIN_MEDIA_PREFIX = '/media/' > > Err, I don't have my code or settings file handy. This is the kind > of thing you forget, since it just works once you have it configured. > > But if you plan to serve media other than admin, you'll want to nest > the admin media dir inside your regular media url. > > So maybe you want MEDIA_URL = http://mysite.com/media/ and > ADMIN_MEDIA_PREFIX = 'http://mysite.com/media/admin/' > >> Anyway, want to say thanks again to everyone for chiming in, this is >> one of the friendliest and most helpful user groups I've had the >> pleasure of participating in. > > That makes me feel kinda fuzzy. :) > -Jeremy > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
On Jul 6, 2:59 pm, John-Scott <[EMAIL PROTECTED]> wrote: > On Jul 6, 12:29 am, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > Hmmm, I'm not sure the documentation is actually accurate. When you > > use manage.py to run up development server for Django, it will > > automatically add the parent directory of where the manage.py file is > > located into sys.path for you. Thus, there isn't strictly a need to > > add it to PYTHONPATH to get it to work in the first place. > > > So, the answer is that YES, for mod_python you must use the PythonPath > > directive to specify the parent directory of where manage.py is > > located in order for your settings file to be found correctly. > > > Graham > > Graham - I was suspicious of that. I remember reading that manage.py > took care of setting all the environment variables for the development > server and interactive shell. But it didn't seem possible for > mod_python to have any idea where our projects are implicitly. Should > we file a doc bug? Someone can correct me, but I think it gets a bit more confusing than that, so there is possibly other changes which should be made to the mod_python documentation. When using manage.py it imports settings.py explicitly, thus there is no need to define DJANGO_SETTINGS_MODULE like with mod_python to say what the actual settings module name is. At this point though, only the directory containing manage.py is effectively in sys.path. This would mean that where you have in urls.py: (r'^mysite1/', include('mysite1.apps.foo.urls.foo')), it would actually fail to find the referenced module. In searching through Django, the only place it adds the parent directory to sys.path so that it might find that referenced module is: def setup_environ(settings_mod): """ Configure the runtime environment. This can also be used by external scripts wanting to set up a similar environment to manage.py. """ # Add this project to sys.path so that it's importable in the conventional # way. For example, if this file (manage.py) lives in a directory # "myproject", this code would add "/path/to/myproject" to sys.path. project_directory = os.path.dirname(settings_mod.__file__) project_name = os.path.basename(project_directory) sys.path.append(os.path.join(project_directory, '..')) project_module = __import__(project_name, {}, {}, ['']) sys.path.pop() If you look carefully, what it does is append the parent directory to sys.path and imports the name of the site directory itself. This has the effect of importing the __init__.py in the site directory. It then removes the parent directory from sys.path. Even though it has removed the parent directory from sys.path, the import of the module referenced in urls.py by the site name still works because of the presence of the 'mysite1' module in sys.modules. Ie., Python sees that module, works out from __file__ of the module where it is located and searches for the submodule relative to that directory. So, importing modules by site package root is okay, but problem is that the site directory itself is still in sys.path. This means one can actually do: (r'^mysite1/', include('apps.foo.urls.foo')), Ie., one can leave out the site name in the module path and it will still work. Some people do imports this way as it means that if you rename the site you don't have to change the urls.py file. Also, easier to develop reusable components that you can copy from one project to another. The problem with this is that if an application which uses these imports without the site name in them is hosted on mod_python, it will not work. This is because not only do you have to set PythonPath to include the parent directory of the site, you also have to list the site directory path itself. Ie., PythonPath "['/path/to/parent','/path/to/parent/mysite1'] + sys.path" I am not sure this is clearly mentioned in the mod_python document for Django or not. Certainly, the need to do this is explained on the mailing list every so often, so there must be some confusion about it. 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: ubuntu 6.06 deployment issues
On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote: > In my settings.py, I now have: > MEDIA_ROOT = '/var/www/mysite.com/media/' > MEDIA_URL = 'http://mysite.com/media/' > ADMIN_MEDIA_PREFIX = '/media/' Err, I don't have my code or settings file handy. This is the kind of thing you forget, since it just works once you have it configured. But if you plan to serve media other than admin, you'll want to nest the admin media dir inside your regular media url. So maybe you want MEDIA_URL = http://mysite.com/media/ and ADMIN_MEDIA_PREFIX = 'http://mysite.com/media/admin/' > Anyway, want to say thanks again to everyone for chiming in, this is > one of the friendliest and most helpful user groups I've had the > pleasure of participating in. That makes me feel kinda fuzzy. :) -Jeremy --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
On Jul 6, 12:29 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > Hmmm, I'm not sure the documentation is actually accurate. When you > use manage.py to run up development server for Django, it will > automatically add the parent directory of where the manage.py file is > located into sys.path for you. Thus, there isn't strictly a need to > add it to PYTHONPATH to get it to work in the first place. > > So, the answer is that YES, for mod_python you must use the PythonPath > directive to specify the parent directory of where manage.py is > located in order for your settings file to be found correctly. > > Graham Graham - I was suspicious of that. I remember reading that manage.py took care of setting all the environment variables for the development server and interactive shell. But it didn't seem possible for mod_python to have any idea where our projects are implicitly. Should we file a doc bug? On Jul 6, 12:20 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > MEDIA_ROOT is used for uploads (like FileField and ImageField. > MEDIA_URL should be the service URL matching MEDIA_ROOT; it is also > used in things like Model.get_FIELD_url where FIELD is the name of an > ImageField on your model. > > Probably, you want your doc root to be some prefix of MEDIA_ROOT (or > MEDIA_ROOT itself). > MEDIA_URL would be the portion of the MEDIA_ROOT not included in your > apache doc root (or '/' if the same). > > ADMIN_MEDIA_PREFIX is the URL portion under MEDIA_URL that is > symlinked to django/contrib/admin/media. (You don't need to worry > about this unless you're using the Admin app.) Jeremy - Thanks for the in-a-nutshell overview. I am in fact using the admin app, so that was my first hurdle to clear before getting fancy. I currently have the admin interface working. In my virtual host file I added: DocumentRoot "/var/www/mysite" SetHandler None SetHandler None In my settings.py, I now have: MEDIA_ROOT = '/var/www/mysite.com/media/' MEDIA_URL = 'http://mysite.com/media/' ADMIN_MEDIA_PREFIX = '/media/' Does this look about right? /var/www/mysite is empty other than the 'media' subdirectory. I suppose I could have apache alias requests to / media/ to whatever folder. I'll get fancy after some sleep ;). Once I get things settled, I'll try to contribute lessons learned to the wiki. Anyway, want to say thanks again to everyone for chiming in, this is one of the friendliest and most helpful user groups I've had the pleasure of participating in. I was born in a small midwestern city not far from Lawrence, KS, so I'm exited to get involved with a web framework of similar origins ;) Cheers --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
On Jul 6, 1:24 pm, John-Scott <[EMAIL PROTECTED]> wrote: > @Vincent - Is specifying the path necessary because I'm using the > development version of django and not an official installer? In the > official docs it says you only have to specify the path "if you've > manually altered your PYTHONPATH to put your Django project on it". I > didn't make any such adjustment. But it's also unclear to me how else > a django project be on the PYTHONPATH. I understand that __init__.py > tells python to load the files in that directory as a module, but > python would need to know what directory to look for that file... Hmmm, I'm not sure the documentation is actually accurate. When you use manage.py to run up development server for Django, it will automatically add the parent directory of where the manage.py file is located into sys.path for you. Thus, there isn't strictly a need to add it to PYTHONPATH to get it to work in the first place. So, the answer is that YES, for mod_python you must use the PythonPath directive to specify the parent directory of where manage.py is located in order for your settings file to be found correctly. 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: ubuntu 6.06 deployment issues
On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote: > (i.e. MEDIA_ROOT, MEDIA_URL, ADMIN_MEDIA_PREFIX) are > supposed to interact with the Apache config. back to the docs... MEDIA_ROOT is used for uploads (like FileField and ImageField. MEDIA_URL should be the service URL matching MEDIA_ROOT; it is also used in things like Model.get_FIELD_url where FIELD is the name of an ImageField on your model. Probably, you want your doc root to be some prefix of MEDIA_ROOT (or MEDIA_ROOT itself). MEDIA_URL would be the portion of the MEDIA_ROOT not included in your apache doc root (or '/' if the same). ADMIN_MEDIA_PREFIX is the URL portion under MEDIA_URL that is symlinked to django/contrib/admin/media. (You don't need to worry about this unless you're using the Admin app.) --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
On Jul 5, 11:33 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > You want to have the 'django_src' directory linked onto your Python > path, not the 'django' directory -- the Python path should contain the > *parent* directories of any modules you want Python to be able to > find. According to http://www.djangoproject.com/documentation/install/, these are the two commands for setting up the development version of django: svn co http://code.djangoproject.com/svn/django/trunk/ django_src ln -s `pwd`/django_src/django SITE-PACKAGES-DIR/django In my case, my `pwd` would be /home/john-scott/workspace, so this is where django_src is created and then the subdirectory `pwd`/django_src/ django would be symlinked to /usr/lib/python2.4/site-packages/django. Am I misunderstanding something? I'm getting sleepy, so anything is possible ;) > Media files to be served directly need to be in a location under the > web server's document root, but templates can be in any location > that's readable by the user the web server is running as, and it's > generally a good idea to have as few Django-related files in the > document root as possible. > > Remember that there are a number of different template loaders > available for Django which can look in different places automatically > -- the "app directories" one, for example, automatically looks inside > any installed application's directory for templates. I guess I was confused by the fact that the settings.py file contains these comments: # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" ...so I assumed it was 'ok' to store all static media files in a similar directory (i.e. '/home/john-scott/workspace/mysite/media'). At this point I realize I'm not at all clear on how the settings in settings.py (i.e. MEDIA_ROOT, MEDIA_URL, ADMIN_MEDIA_PREFIX) are supposed to interact with the Apache config. back to the docs... --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
On 7/5/07, John-Scott <[EMAIL PROTECTED]> wrote: > @Nimrod - You were right about the permissions on /home/john-scott/ > workspace, chmod 755 fixed that. But I still have to have the django > development code in /opt to get it to load. Any ideas why symlinking > to /home/john-scott/workspace/django_src/django doesn't work? You want to have the 'django_src' directory linked onto your Python path, not the 'django' directory -- the Python path should contain the *parent* directories of any modules you want Python to be able to find. > And where do you typically keep the template and/or admin media files? > Can these be kept in /home/john-scott/workspace/mysite/{templates| > admin_media} etc.? Or do these have to be placed under /var/www? Media files to be served directly need to be in a location under the web server's document root, but templates can be in any location that's readable by the user the web server is running as, and it's generally a good idea to have as few Django-related files in the document root as possible. Remember that there are a number of different template loaders available for Django which can look in different places automatically -- the "app directories" one, for example, automatically looks inside any installed application's directory for templates. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
Thanks for the prompt replies. @Nimrod - You were right about the permissions on /home/john-scott/ workspace, chmod 755 fixed that. But I still have to have the django development code in /opt to get it to load. Any ideas why symlinking to /home/john-scott/workspace/django_src/django doesn't work? @Vincent - Is specifying the path necessary because I'm using the development version of django and not an official installer? In the official docs it says you only have to specify the path "if you've manually altered your PYTHONPATH to put your Django project on it". I didn't make any such adjustment. But it's also unclear to me how else a django project be on the PYTHONPATH. I understand that __init__.py tells python to load the files in that directory as a module, but python would need to know what directory to look for that file... And where do you typically keep the template and/or admin media files? Can these be kept in /home/john-scott/workspace/mysite/{templates| admin_media} etc.? Or do these have to be placed under /var/www? Thanks again --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
Try adding the following in the location block: PythonPath "['/home/john-scott/workspace'] + sys.path" Vincent On 7/5/07 9:03 PM, "John-Scott" <[EMAIL PROTECTED]> wrote: > > Hello all, > > I'm having some issues getting a basic django project in production > mode. > > I'm using Ubuntu 6.06 LTS with the default versions of apache, python, > mod_python, etc. > - I've checked out the development version of Django in my home > directory, i.e. /home/john-scott/workspace/django_src and I've > symlinked it to /usr/lib/python2.4/site-packages/django as per the > official installation instructions. > - I've created a Django project in /home/john-scott/workspace/mysite > following the tutorials exactly. > > The official documentation suggests keeping the django app code > outside of /var/www for security purposes and to instead keep the code > in a user directory (the specific example is '/home/mycode'). > Everything works great with the development server. However, I've > encountered nothing but problems trying to go 'live'. I'm using the > following virtual host configuration, which again is modeled after the > official docs: > > > ServerNamemysite.com #obviously not the real url ;) > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE mysite.settings > PythonDebug On > > > > With this setup I get the following error: > ImportError: No module named django > > In another thread (http://groups.google.com/group/django-users/ > browse_thread/thread/e44569d185e36284/) someone said there were > permission problems but their solution was to place the django_src in / > opt and change the symlink accordingly. If I follow this, then the > first problem goes away but then I get the following error: > EnvironmentError: Could not import settings 'mysite.settings' (Is it > on sys.path? Does it have syntax errors?): No module named > mysite.settings > > In the same thread the user also put the projects in /opt as well. The > real problem seems to be the Apache configuration, so I'm not > convinced the answer is to throw everything in /opt, especially since > none of the official docs suggest to do such a thing (IIRC the user in > that thread didn't have control over apache, so they had to be > creative). > > I've followed all the official docs quite literally. Is the suggestion > in the docs to keep your projects in /home/username incorrect? Or is > there something about the Apache configuration in Ubuntu 6.06 that > makes deployment a wee bit more complicated than the docs suggest? If > so, should the official deployment guides have a note about these > gotchas? Once I get this ironed out in a sane way I'd be happy to add > a write-up to the SeverArrangements wiki page. > > Thanks, > John-Scott > > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~-~--~~~---~--~~ 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: ubuntu 6.06 deployment issues
Hello, Your problem could be that the permissions to /home/john-scott do not allow directory traversal down into this directory for "other" users. You probably need to do: $ chmod 0755 /home/john-scott $ chmod 0755 /home/john-scott/workspace $ cd /home/john-scott/workspace $ find -type d | xargs chmod 0755 $ find -type f | xargs chmod 0644 Your home directory probably contains important files that you don't want to be accessible by "other" users so you might consider creating a separate user account specifically for Django. HTH. On 7/6/07, John-Scott <[EMAIL PROTECTED]> wrote: > > Hello all, > > I'm having some issues getting a basic django project in production > mode. > > I'm using Ubuntu 6.06 LTS with the default versions of apache, python, > mod_python, etc. > - I've checked out the development version of Django in my home > directory, i.e. /home/john-scott/workspace/django_src and I've > symlinked it to /usr/lib/python2.4/site-packages/django as per the > official installation instructions. > - I've created a Django project in /home/john-scott/workspace/mysite > following the tutorials exactly. > > The official documentation suggests keeping the django app code > outside of /var/www for security purposes and to instead keep the code > in a user directory (the specific example is '/home/mycode'). > Everything works great with the development server. However, I've > encountered nothing but problems trying to go 'live'. I'm using the > following virtual host configuration, which again is modeled after the > official docs: > > > ServerNamemysite.com #obviously not the real url ;) > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJANGO_SETTINGS_MODULE mysite.settings > PythonDebug On > > > > With this setup I get the following error: > ImportError: No module named django > > In another thread (http://groups.google.com/group/django-users/ > browse_thread/thread/e44569d185e36284/) someone said there were > permission problems but their solution was to place the django_src in / > opt and change the symlink accordingly. If I follow this, then the > first problem goes away but then I get the following error: > EnvironmentError: Could not import settings 'mysite.settings' (Is it > on sys.path? Does it have syntax errors?): No module named > mysite.settings > > In the same thread the user also put the projects in /opt as well. The > real problem seems to be the Apache configuration, so I'm not > convinced the answer is to throw everything in /opt, especially since > none of the official docs suggest to do such a thing (IIRC the user in > that thread didn't have control over apache, so they had to be > creative). > > I've followed all the official docs quite literally. Is the suggestion > in the docs to keep your projects in /home/username incorrect? Or is > there something about the Apache configuration in Ubuntu 6.06 that > makes deployment a wee bit more complicated than the docs suggest? If > so, should the official deployment guides have a note about these > gotchas? Once I get this ironed out in a sane way I'd be happy to add > a write-up to the SeverArrangements wiki page. > > Thanks, > John-Scott > > > > > -- _nimrod_a_abing_ http://abing.gotdns.com/ http://www.preownedcar.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
ubuntu 6.06 deployment issues
Hello all, I'm having some issues getting a basic django project in production mode. I'm using Ubuntu 6.06 LTS with the default versions of apache, python, mod_python, etc. - I've checked out the development version of Django in my home directory, i.e. /home/john-scott/workspace/django_src and I've symlinked it to /usr/lib/python2.4/site-packages/django as per the official installation instructions. - I've created a Django project in /home/john-scott/workspace/mysite following the tutorials exactly. The official documentation suggests keeping the django app code outside of /var/www for security purposes and to instead keep the code in a user directory (the specific example is '/home/mycode'). Everything works great with the development server. However, I've encountered nothing but problems trying to go 'live'. I'm using the following virtual host configuration, which again is modeled after the official docs: ServerNamemysite.com #obviously not the real url ;) SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonDebug On With this setup I get the following error: ImportError: No module named django In another thread (http://groups.google.com/group/django-users/ browse_thread/thread/e44569d185e36284/) someone said there were permission problems but their solution was to place the django_src in / opt and change the symlink accordingly. If I follow this, then the first problem goes away but then I get the following error: EnvironmentError: Could not import settings 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings In the same thread the user also put the projects in /opt as well. The real problem seems to be the Apache configuration, so I'm not convinced the answer is to throw everything in /opt, especially since none of the official docs suggest to do such a thing (IIRC the user in that thread didn't have control over apache, so they had to be creative). I've followed all the official docs quite literally. Is the suggestion in the docs to keep your projects in /home/username incorrect? Or is there something about the Apache configuration in Ubuntu 6.06 that makes deployment a wee bit more complicated than the docs suggest? If so, should the official deployment guides have a note about these gotchas? Once I get this ironed out in a sane way I'd be happy to add a write-up to the SeverArrangements wiki page. Thanks, John-Scott --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---