设置DJANGO_SETTINGS_MODULE环境变量

时间:2019-12-04 04:46:14

标签: python django django-manage.py

我有一个Django项目,该项目是从以前的开发人员那里获得的,并且我正在设置本地测试环境。我可以成功使manage.py运行服务器正常运行,没有任何错误,但是无法访问127.0.0.1:8000或localhost:8000。我收到错误消息“找不到此127.0.0.1页面”。在我对该问题的研究中,我怀疑问题出在我的manage.py或设置上。如何解决这个问题。请帮忙。 以下是我的manage.py文件。

import os
import sys
import django

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Project.settings")
    try:
        from django.core.management import execute_from_command_line
    except ImportError:
        # The above import may fail for some other reason. Ensure that the
        # issue is really that Django is missing to avoid masking other
        # exceptions on Python 2.
        try:
            import django
        except ImportError:
            raise ImportError(
                "Couldn't import Django. Are you sure it's installed and "
                "available on your PYTHONPATH environment variable? Did you "
                "forget to activate a virtual environment?"
            )
        raise
    execute_from_command_line(sys.argv)

0 个答案:

没有答案