Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入Django项目的设置_Python_Mysql_Django_Path_Sys - Fatal编程技术网

Python 导入Django项目的设置

Python 导入Django项目的设置,python,mysql,django,path,sys,Python,Mysql,Django,Path,Sys,在读完Django教程之后,我尝试用MYSQL而不是SQLite启动我自己的项目。我还改变了我项目的结构,我相信这就是我与导入发生冲突的地方 目前的项目结构 moerepo moesite manage.py moesite __init__.py urls.py wsgi.py settings base.py

在读完Django教程之后,我尝试用MYSQL而不是SQLite启动我自己的项目。我还改变了我项目的结构,我相信这就是我与导入发生冲突的地方

目前的项目结构

moerepo
   moesite
        manage.py
        moesite
            __init__.py
            urls.py
            wsgi.py
            settings
                base.py
                __init__.py
                local.py
                staging.py
                test.py
                production.py
我目前的最终目标是让我的项目在本地配置一个MYSQL数据库。但是,我在导入基本设置以运行syncdb命令时遇到问题

当我运行python manage.py syncdb--settings=settings.base时。。。我收到下面的错误

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/alpha/django-trunk/django/core/management/__init__.py", line 427, in    execute_from_command_line
utility.execute()
File "/home/alpha/django-trunk/django/core/management/__init__.py", line 386, in execute
settings.INSTALLED_APPS
File "/home/alpha/django-trunk/django/conf/__init__.py", line 46, in __getattr__
self._setup(name)
File "/home/alpha/django-trunk/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/home/alpha/django-trunk/django/conf/__init__.py", line 98, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'settings.base' (Is it on sys.path? Is there an    import error in the settings file?): No module named settings.base
显然不需要,但我已经在我的base.py中附加了应该是适当目录的内容

"""Path Configuration"""
DJANGO_ROOT = dirname(dirname(abspath(__file__)))
"""Site Name"""
SITE_NAME = basename(DJANGO_ROOT)

"""Abs filesystem path to the top-level project folder."""
SITE_ROOT = dirname(DJANGO_ROOT)

"""Absolute filesystem path to the secret file which holds the SECRET_KEY. Will be
auto generated the first time this file is interpreted"""
SECRET_FILE = normpath(join(SITE_ROOT, 'deploy', 'SECRET'))

"""Add all necessary filesystem paths to our system path so that we can use
python import statements"""
sys.path.append(SITE_ROOT)
sys.path.append(normpath(join(DJANGO_ROOT, 'apps')))
sys.path.append(normpath(join(DJANGO_ROOT, 'libs')))
任何指导都将不胜感激。如果我需要提供更具体的信息,或者如果有不相关的信息,请告诉我,以便我可以使此处的所有信息都相关。

请尝试使用

--settings=moesite.settings.base

在大多数情况下,
base.py
并不像抽象类那样直接使用,而是通过一些其他设置进行扩展,如
local
production
等。因此,也许您应该尝试其中一种,或者再次比较差异并将应该追加的内容追加到基本文件中。数据库部分的配置在哪里?它合适吗?如果可以的话,将您的项目推送到github,这样会更容易帮助您,至少推送所有的config files.gah是如此简单。这让我达到了我想要的地方,但我确实在基本设置文件中有一些进一步的错误需要解决。再次感谢!!!
--settings=moesite.settings.base