django-admin.py 无法正常工作
我刚刚发现我的 django-admin.py 命令有问题。我检查了有关 django-admin.py 问题的类似 SO 帖子,但似乎没有任何内容与我的问题相关。我使用 Windows Vista(是的,我知道......)。我的磁盘上的某个文件夹中还有许多版本的 django,我使用 junction 命令(这类似于 unix 中的符号链接),我对此没有任何问题,以前也从未遇到过问题。
我之前多次使用 django-admin.py 但现在由于一些未知的原因我得到了这个信息(Django 1.1.1):
C:\>django-admin.py startproject some_project
Type 'django-admin.py help' for usage.
令人惊讶的是当我输入 django 要求我输入的内容时:
C:\>django-admin.py help
Type 'django-admin.py help' for usage.
????
当我切换到 Django 1.2.1 时,我得到了这个:
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
它总是显示相同的消息。
有什么想法吗?
编辑:新信息
我刚刚注意到,当 django managament 实用程序解析命令时,我的命令行参数不可见(当我打印命令 argv 时,它仅显示 django-admin.py 的路径,没有任何给定参数)
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.
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.
and suprisingly when I type what django asked me to type:
C:\>django-admin.py help
Type 'django-admin.py help' for usage.
????
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
no matter if I type startproject help
or startproject some_name
it always shows the same message.
Any ideas?
EDIT: new info
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的问题是我丢失了 .py 文件关联规则。
如果你有类似的问题,你可以在命令行中检查结果是什么:
如果没有这样的关联,你需要创建它:
并为 Python.File 创建规则:(
替换为你的 python 解释器的路径。)
现在 django-admin.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:
If there is no such association you need to create it:
and create rule for Python.File:
(Replace with whatever the path is to your python interpretter.)
now django-admin.py accepts command line args and everything works fine!
这会更好,因为它根本不需要触摸注册表:
https://stackoverflow.com/a/10732170/1585863
This would be better as it does not require touching the registry at all:
https://stackoverflow.com/a/10732170/1585863