Django项目初始设置中的问题 [英] Issues in initial setup for django project
问题描述
我正在从官方文档中学习Django,并在 https://docs.djangoproject.com/en/1.7/intro/tutorial01/,我被困在创建项目部分中.
I am learning Django from the official documentation and while going through the tutorial at https://docs.djangoproject.com/en/1.7/intro/tutorial01/, I am stuck at creating a project part.
当我运行 django-admin.py startproject mysite
时,出现以下错误
When I run django-admin.py startproject mysite
I am getting following error
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核心命令,因为未正确配置设置
Note that only Django core commands are listed as settings are not properly configured
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.).
我正在使用Python 3.4.1和django 1.7.我没有安装任何其他Django版本,这是我正在创建的第一个项目.
I am using Python 3.4.1 and django 1.7. I don't have any other Django version installed and this is the first project I am creating.
推荐答案
Make sure that you follow the troubleshooting guide because it looks like you don't have django-admin.py on your system path correctly. From the docs:
如果安装了Django,则django-admin.py应该位于系统路径上通过python setup.py.如果不在您的路线上,您可以在以下位置找到它site-packages/django/bin,其中site-packages是其中的目录您的Python安装.考虑从以下链接到django-admin.py进行符号链接路径上的某个位置,例如/usr/local/bin.
django-admin.py should be on your system path if you installed Django via python setup.py. If it’s not on your path, you can find it in site-packages/django/bin, where site-packages is a directory within your Python installation. Consider symlinking to django-admin.py from some place on your path, such as /usr/local/bin.
对于每个项目,您还应该使用 virtualenv 以允许隔离依赖项每个项目,更易于管理. virtualenvwrapper 是创建和管理虚拟环境的有用工具.
You should also use a virtualenv for each of your projects to allow isolation of dependencies per project and easier management of them. virtualenvwrapper is a useful tool for creating and managing your virtualenvs.
这篇关于Django项目初始设置中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!