简体   繁体   中英

django-admin.py is not working

Am new to django and i have been trying to set up a project with no success. When i type django-admin.py startproject mysite i get this.

C:\Users\WASSWA SAM\Documents\django\djcode>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]

Options:
  -v VERBOSITY, --verbosity=VERBOSITY
                    Verbosity level; 0=minimal output, 1=normal output,
                    2=all output

etc....

I have added it to my path like so

C:\Python26\Lib\site-packages\django\bin

And when i import django from interactive mode it works perfectly. What could be the problem. I am using Windows 7 and django 1.3.1. I installed it using setup.py.

I had the same problem; I found a working solution at https://groups.google.com/forum/#!msg/django-users/b76qSG3mV6g/jP1o0ny3i2kJ :

python C:\Python27\Scripts\django-admin.py startproject mysite

This is an error with Python's installation on Windows. If you have the regkey entry

HKEY_CLASSES_ROOT\py_auto_file\shell\command\open\

change the value from

"C:\Python27\python.exe" "%1"

to

"C:\Python27\python.exe" "%1" %*

(Or your equivalent installation location)

This ensures that command-line arguments are passed onto python, rather than explicitly ignored. This is fixed in the latest install of Python 2.7. %* is argv[] . "%1" is the script's absolute path.

I had the same problem and could not solve it for hours. Create a new project from Pycharm or any other program you are using, install Django and then instead of running

django-admin.py startproject *project_name* .

run

django-admin startproject *project_name* .

Ommiting .py extension worked for me and everything is running as expected now.

I don't think you need to have django\\bin in the path.

I think what you need to add to your PATH though is C:\\Python26\\scripts and then you should be able to run the startproject script.

In my case, I use eclipse and you can start an eclipse project from within the eclipse environment using PyDev.

Go up to File > New > Other > (within the PyDev Folder) > PyDev Django Project. In the wizard it will allow you to setup most of the commonly used features of Django.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM