I thought that it was best practice to not put python code in /var/www
and to own the code with an unprivileged user.  Doesn't seem like it
is necessarily germane to the present topic but perhaps something to
think about.

Am I wrong? Are there exceptions?  I think I have seen some high
profile websites running application code under /var/www



Stodge wrote:
> This:
>
>               sys.path.append("/var/www/sites/indigo/")
>               os.environ['DJANGO_SETTINGS_MODULE'] = 'indigo.settings'
>               from django.core.management import setup_environ
>               import settings
>               project_directory = setup_environ(settings)
>               from indigo.project.ticket.models import Ticket
>
> Gives me "ImportError: No module named project.ticket.models". Hmmm.
> So it can import the settings before calling setup_environ but the
> environment isn't unusable afterwards.
>
>
> On Dec 1, 12:51 pm, Stodge <sto...@gmail.com> wrote:
> > Argh! Taking this a step further - I'm now trying to access my Django
> > environment from within a Trac (http://trac.edgewall.org) plugin, but
> > I'm getting a similar issue.
> >
> > This works:
> >
> >                 sys.path.append("/var/www/sites/indigo/")
> >                 os.environ['DJANGO_SETTINGS_MODULE'] = 'indigo.settings'
> >                 from django.core.management import setup_environ
> >                 import settings
> >                 project_directory = setup_environ(settings)
> >
> > But this:
> >
> >                 sys.path.append("/var/www/sites/indigo/")
> >                 os.environ['DJANGO_SETTINGS_MODULE'] = 'indigo.settings'
> >                 from django.core.management import setup_environ
> >                 import settings
> >                 project_directory = setup_environ(settings)
> >                 from django.contrib.auth.models import User
> >
> > Gives "ImportError: Could not import settings 'indigo.settings' (Is it
> > on sys.path? Does it have syntax errors?): No module named settings"
> >
> > It's the exact same code that works in my Mercurial plugin. Any ideas?
> > Thanks

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to