我正在从官方文档中学习Django,在学习https://docs.djangoproject.com/en/1.7/intro/tutorial01/的教程时,我一直在创建项目部分。
当我运行django-admin.py startproject mysite
时,出现以下错误
C:\Python34>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
--settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Raise on exception
--no-color Don't colorize the command output.
--version show program's version number and exit
-h, --help show this help message and exit
Type 'django-admin.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runfcgi
runserver
shell
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlinitialdata
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
syncdb
test
testserver
validate
注意,只有Django core命令被列为未正确配置的设置
error: Requested setting INSTALLED_APPS, but settings are not configured
. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).
我使用的是Python3.4.1和Django1.7。我没有安装任何其他Django版本,这是我正在创建的第一个项目。
确保遵循troubleshooting guide,因为看起来系统路径上没有django-admin.py。从文档中:
您还应该为每个项目使用一个virtualenv,以便隔离每个项目的依赖项并简化对它们的管理。virtualenvwrapper是创建和管理虚拟机的有用工具。
您只需运行
django-admin startproject mysite
(注意:不是django-admin.py
),因为如果通过pip安装django,名为“django admin.exe”的可执行程序将被添加到环境变量“PATH”中的“C:\ Python34\Scripts”(如果不是,则将其添加到PATH)。相关问题 更多 >
编程相关推荐