Wednesday, February 27, 2013

Re: manage.py and django-admin.py help

On 28/02/2013 11:02am, Clientkill wrote:
> It appears that Settings cannot be imported, because environment
> variable DJANGO_SETTINGS_MODULE is undefined. I did a google search on
> this, but it reared no valuable results. Can anyone help?

Your wsgi file (the server's entry-point for the site) needs to put your
project into sys.path

Here is mine ...
------------------------------------
from __future__ import unicode_literals
# -*- coding: utf-8 -*-
# application entry point

site = "mysite"
project = "myproject"
srvroot = "/var/www"
site_root = "%s/%s" % (srvroot, site)
project_root = "%s/%s" % (site_root, project)

import os
import sys

if site_root not in sys.path:
sys.path.insert(0, site_root)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % project)
os.environ.setdefault("PYTHON_EGG_CACHE", site_root)
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
---------------------------------------

IIRC, having __init__.py in site_root makes this work. Otherwise I think
I might have previously used project_root instead.

hth

Mike


>
>
> On Wednesday, 27 February 2013 17:27:01 UTC-5, Clientkill wrote:
>
> Can someone tell me why, even after trying everything, I can't open
> either manage.py or django-admin.py? I have apt-get installed django
> and its registration package, and calling manage.py or
> django-admin.py returns:
> manage.py: command not found
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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

No comments:

Post a Comment