django - 如何手动设置sys.path?

时间:2015-03-31 22:41:44

标签: django

直到现在我在我的django生产服务器上进行了更改(是的,非常非常糟糕:p)。我想去一个git进程,并在部署之前创建一个本地测试服务器。所以,我下载了我的python文件,并运行了一个:

python manage.py runserver
希望并祈祷......但这还不够,我得到了一个很好的错误:

django.core.exceptions.ImproperlyConfigured: WSGI application 'issc.issc.wsgi.application' could not be loaded; Error importing module: 'No module named issc.wsgi'

我在documentation中读到自动创建[manage.py]并设置了几个关键部分:

In addition, manage.py is automatically created in each Django project. manage.py is a thin wrapper around django-admin.py that takes care of several things for you before delegating to django-admin.py:
  It puts your project’s package on sys.path.
    It sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s settings.py file.
    It calls django.setup() to initialize various internals of Django.

我的问题是:如何手动设置这些变量?因为在我的情况下我下载了任意目录上的所有文件,但这还不够。 Eveything在这里,但它缺少与这一切的链接......

1 个答案:

答案 0 :(得分:0)

如果您想手动设置配置文件的地址,可以使用以下内容设置DJANGO_SETTINGS_MODULE

export DJANGO_SETTINGS_MODULE='settings_to_load'

您可以通过这种方式设置所有环境变量,它应该可以正常工作。我建议至少使用Virtualenv。

相关问题