python manage.py迁移不起作用,runserver也不起作用
我成功地安装了mysql。但当我尝试运行以下命令时 -python manage.py makemigrations -python manage.py syncdb 它给了我这个错误 导入错误:没有名为python.settings的模块 我的wsgi.py文件包含 导入操作系统 从django.core.wsgi导入获取\u wsgi\u应用程序 os.environ.setdefault(“DJANGO\u设置\u模块”、“公文包.SETTINGS”) application=get\u wsgi\u application()python manage.py迁移不起作用,runserver也不起作用,python,mysql,django,python-2.7,Python,Mysql,Django,Python 2.7,我成功地安装了mysql。但当我尝试运行以下命令时 -python manage.py makemigrations -python manage.py syncdb 它给了我这个错误 导入错误:没有名为python.settings的模块 我的wsgi.py文件包含 导入操作系统 从django.core.wsgi导入获取\u wsgi\u应用程序 os.environ.setdefault(“DJANGO\u设置\u模块”、“公文包.SETTINGS”) application=get\u
注:我正在使用ubuntu 14.04,另外python manage.py runserver命令中也有相同的错误。我正在运行一个类似的服务器设置(ubuntu 14.04、Apache、mod_wsgi),在我们的wsgi.py文件中,我们必须做两件事来确保它工作正常。我们使用了顶级应用程序目录的导入,还有一个多文件(不是django默认)设置结构,并且必须调整设置文件的规范 例如,我们的文件夹结构是:
project-directory
- manage.py
- static
- app1-directory
- settings # a directory, not a file
- development.py
- quality_assurance.py
- production.py
- wsgi.py
- app2-directory
在wsgi.py文件中,我们需要在setdefault行之前包含此指令:
import sys
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
我们所做的第二个更改是指定确切的设置文件,因此我们使用以下示例代替“app1 directory.settings”:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app-name.settings.quality_assurance")
您的问题也可能是由于命名空间冲突造成的: