django-admin.py无法正常工作 [英] django-admin.py is not working properly

查看:234
本文介绍了django-admin.py无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现我的django-admin.py命令有问题。我检查过类似的SO职位django-admin.py问题,但似乎没有与我的问题相关。我使用Windows Vista(是的,我知道...)。我也有许多版本的django在我的磁盘上的某个文件夹,我切换到我需要使用 junction 命令(这与unix中的符号链接类似),我没有问题,从来没有遇到过问题。



使用django-admin.py很多次,但现在由于一些未知的原因我得到这个信息(Django 1.1.1):

  C:\> django-admin.py startproject some_project 
键入'django-admin.py help'以获取使用。

令人惊讶的是,当我键入什么django要求我键入:

  C:\> django-admin.py help 
键入'django-admin.py help'以供使用。



切换到Django 1.2.1我得到这个:

  C:\> django-admin.py startproject help 
用法:django-admin.py子命令[options] [args]

选项:
-v VERBOSITY,--verbosity = VERBOSITY
详细程度; 0 =最小输出,1 =正常输出,
2 =所有输出
--settings = SETTINGS设置模块的Python路径,例如。
myproject.settings.main。如果没有提供,则
DJANGO_SETTINGS_MODULE环境变量将使用

--pythonpath = PYTHONPATH
要添加到Python路径的目录,例如
/ home / djangoprojects / myproject。
--traceback打印traceback上的异常
--version显示程序的版本号并退出
-h,--help显示此帮助消息并退出

键入' django-admin.py help< subcommand>'以获取有关特定子命令的帮助。

可用的子命令:
cleanup
compilemessages
createcachetable
...
startproject
...
validate无论我键入 startproject help 还是
startproject some_name 它总是显示相同的讯息。



有任何想法吗?



编辑:新信息



我刚刚注意到,当命令被django解析时,我的命令行参数不可见

解决方案

当我打印命令argv时,它只显示没有任何给定参数的django-admin.py的路径。问题在我的情况是我丢失了.py文件关联规则。



如果你有类似的问题,你可以在命令行检查的结果是什么: p>

  assoc .py 


$ b b

如果没有这样的关联,您需要创建它:

  assoc .py = Python.File 

并为Python.File创建规则:

  ftype Python.File =c:\python27\python.exe%1%* 

(替换为你的Python解释器的路径。)



现在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)

解决方案

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

and create rule for Python.File:

ftype Python.File="c:\python27\python.exe" "%1" %*

(Replace with whatever the path is to your python interpretter.)

now django-admin.py accepts command line args and everything works fine!

这篇关于django-admin.py无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆