Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
976 views
in Technique[技术] by (71.8m points)

shell - django-admin.py is not working properly

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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:python27python.exe" "%1" %*

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...