django-admin.py 无法正常工作 [英] django-admin.py is not working properly
问题描述
我刚刚发现我的 django-admin.py 命令有问题.我检查了关于 django-admin.py 问题的类似 SO 帖子,但似乎与我的问题无关.我使用 Windows Vista(是的,我知道...).我的磁盘上的某个文件夹中也有许多版本的 django,我使用 junction 命令(这类似于 unix 中的符号链接),我对此没有任何问题,以前从未遇到过问题.
I have just spotted that something is wrong with my django-admin.py command. I checked similar SO posts on django-admin.py problems but nothing seems to be related to my problem. I use Windows Vista (yeah, I know...). I also have many versions of django in some folder on my disk and I switch to the version I need using junction command (this is similar to symlinking in unix), I don't have problems with this and never had problems before.
我以前多次使用 django-admin.py,但现在由于某些未知原因我得到了这个信息(Django 1.1.1):
I used django-admin.py many times before but now for some unknown reasons I got this info (Django 1.1.1):
C:>django-admin.py startproject some_project
Type 'django-admin.py help' for usage.
当我输入 django 要求我输入的内容时,令人惊讶的是:
and suprisingly when I type what django asked me to type:
C:>django-admin.py help
Type 'django-admin.py help' for usage.
??????
当我切换到 Django 1.2.1 时,我得到了这个:
When I switch to Django 1.2.1 I got this:
C:>django-admin.py startproject help
Usage: django-admin.py subcommand [options] [args]
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=all 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 Print traceback on exception
--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:
cleanup
compilemessages
createcachetable
...
startproject
...
validate
无论我输入 startproject help
还是 startproject some_name
,它总是显示相同的消息.
no matter if I type startproject help
or startproject some_name
it always shows the same message.
有什么想法吗?
新信息
我刚刚注意到,当命令被 django managament utlity 解析时,我的命令行参数不可见(当我打印命令 argv 时,它只显示 django-admin.py 的路径而没有任何给定的参数)
I've just noticed that my command line arguments are not visible when command is parsed by django managament utlity (when I print command argv it shows only path to django-admin.py without any of given arguments)
推荐答案
我的问题是我丢失了 .py 文件关联规则.
The problem in my case was the I've lost .py file association rules.
如果你有类似的问题,你可以在命令行中检查结果是什么:
If you have similar problem you can check in command line what is the result of:
assoc .py
如果没有这样的关联你需要创建它:
If there is no such association you need to create it:
assoc .py=Python.File
并为 Python.File 创建规则:
and create rule for Python.File:
ftype Python.File="c:python27python.exe" "%1" %*
(替换为您的 python 解释器的任何路径.)
(Replace with whatever the path is to your python interpretter.)
现在 django-admin.py 接受命令行参数并且一切正常!
now django-admin.py accepts command line args and everything works fine!
这篇关于django-admin.py 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!