2

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.

Wasswa Samuel
  • 2,139
  • 3
  • 30
  • 54
  • does `django-admin.py help startproject` work (eg, print the startproject usage & description)? – AdamKG Jan 24 '12 at 16:00
  • See the second answer to [this question](http://stackoverflow.com/questions/2870262/django-admin-py-startproject-mysite-not-working-well-on-windows-7). – Daniel Roseman Jan 24 '12 at 16:28
  • django-admin.py help startproject gives the same output. And the second answer to http://stackoverflow.com/questions/2870262/django-admin-py-startproject-mysite-not-working-well-on-windows-7 doesn't work either. Am stuck – Wasswa Samuel Jan 25 '12 at 16:42

4 Answers4

3

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
akrolsmir
  • 312
  • 1
  • 4
  • 14
3

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.

Amelia
  • 2,967
  • 2
  • 24
  • 39
  • Why the downvote, may I ask? It was fixed in 2.7.3 but if you had previous installations the regkeys were not updated. – Amelia Mar 01 '13 at 23:56
1

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.

DjoleRkc
  • 135
  • 7
  • 1
    Yes for some reason omitting the python file extension works. First time this has happened to me. I gave you an upvote because I feel this to be an underrated 'contemporary' solution. – andres Oct 29 '20 at 05:22
-1

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.

James R
  • 4,571
  • 3
  • 30
  • 45