Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django-admin.py prints help only

Tags:

python

django

I am using django 1.3.1

I followed the online tutorial and tried to use "django-admin.py startproject mysite".

But I always receive this:

D:\Code\djtest>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
(...)

What is going on?

like image 741
Munichong Avatar asked Feb 02 '12 04:02

Munichong


People also ask

Why Django admin command is not working?

command not found: django-admin django-admin should be on your system path if you installed Django via pip . If it's not in your path, ensure you have your virtual environment activated and you can try running the equivalent command python -m django .

What is the difference between Django admin and manage py?

Django-admin.py: It is a Django's command line utility for administrative tasks. Manage.py: It is an automatically created file in each Django project. It is a thin wrapper around the Django-admin.py.

Can we customize Django admin panel?

The Django admin is a powerful built-in tool giving you the ability to create, update, and delete objects in your database using a web interface. You can customize the Django admin to do almost anything you want.

What does admin py do in Django?

The admin.py file is used to display your models in the Django admin panel. You can also customize your admin panel. Hope this helps you.


1 Answers

I had exactly the same problem and solved it using this tool: FileTypesManager

The problem is that django-admin.py is not receiving the correct arguments from the command line. I did a test by hacking a couple of lines into the front of the admin script to display the number of arguments and what they were before it did anything else. The hack:

    #!d:\python27\python.exe
    from django.core import management
    import sys
    print 'Number of arguments:', len(sys.argv), 'arguments.'
    print 'Argument List:', str(sys.argv)

    if __name__ == "__main__":
       management.execute_from_command_line()

When you run django-admin.py you will see that there is only 1 argument ever being passed. Which is not correct.

As suggested in several forums, I tried both of the following at the command line, and both looked spot on:

    assoc .py            -->  .py=Python.File
    ftype Python.File    -->  Python.File="D:\Python27\python.exe" "%1" %*   //Correct

I then looked in the registry and the values looked good as well.

However, when I ran FileTypesManager, (it's free) it showed something different. The command-line was set as:

   "D:\Python27\python.exe" "%1"      //Wrong!

I have no idea why, but as soon as I updated this value it all worked flawlessly.

I hope that helps.

like image 135
croc Avatar answered Sep 19 '22 06:09

croc