after installing django I tried django-admin.py startproject mysite
and that worked, then I got a simple site working and I wanted to start on something real, so I tried django-admin.py startproject newsite
and nothing happened. Whenever I try the command nothing happens now.. any idea what is wrong?

- 15,988
- 11
- 54
- 98
15 Answers
For anyone stumbling across this now, this problem is a result of Windows not obeying the #!C:\Path\To\Virtualenv\Scripts\Python.exe hashbang at the top of django-admin.py, and therefore running it with the wrong python.exe (evidently a virtualenv bug).
However, with virtualenv active, you can use the following command, which will result in the correct python being used, and everything being ok:
python C:\Path\To\Virtualenv\Scripts\django-admin.py startproject <project_name>

- 766
- 6
- 2
-
9or python C:\Python27\Scripts\django-admin.py startproject
works without using virtualenv - Thanks! – Sweet Burlap Jan 04 '13 at 09:42 -
The answer is so simple, yet somehow I missed it. Thanks for the help! – DigiOz Multimedia Sep 26 '17 at 03:31
-
You can as well copy django-admin.py to your working directory. – Cletus Ajibade Jan 04 '18 at 16:00
If you are running Windows for a quick fix you can create a batch file with the following values:
@echo off
@echo "Enter Proyect name"
set /p proj_name=
set building="Building django project %proj_name%"
@echo %building%
python c:/Python27/Scripts/django-admin.py startproject %proj_name%
pause
I named the file "django.bat" and to use it you can just simply add a copy in the directory you want to start the project, execute the file and it will ask you for a project name, provide one and then Voila!!
Hope this helps.

- 1,413
- 4
- 21
- 30
-
Thanks your django.bat is indeed helpful before this i was getting error as ImportError: Could not import settings 'mysite.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'mysite' but batch file help me to solve my problem... Thanks once again – CY5 Jan 30 '15 at 16:43
Do you have a DJANGO_SETTINGS_MODULE
environment variable set (presumably from the mysite
project)? If so, django thinks you're working on the old project and doesn't give you the startproject
option. Try unsetting the environment variable and trying again.

- 120,335
- 23
- 147
- 134
-
"Do you have a DJANGO_SETTINGS_MODULE environment variable set?" how do I check this? – erikvold Sep 10 '10 at 22:21
-
@Erik: On unix: `echo $DJANGO_SETTINGS_MODULE` and on windows: `echo %DJANGO_SETTINGS_MODULE%` at the command line. – ars Sep 10 '10 at 22:59
-
-
OK, so the variable isn't set. Have you tried executing django-admin startproject again? Same problem? – ars Sep 11 '10 at 22:58
-
ya same problem, it appears that notepad++ is opening django-admin.py whenever I run `django-admin.py startproject something`.. – erikvold Sep 12 '10 at 23:22
-
1@erikvold You probably have set that *.py files are opened by notepad++ by default. You should try to change default opening to python. (properties-> open with...) – Milano Feb 19 '15 at 13:06
-
Clearing an old `DJANGO_SETTINGS_MODULE` worked for me. For balance; windows clear is `>set DJANGO_SETTINGS_MODULE=` applying nothing after the `=` – Glycerine Nov 10 '16 at 23:18
Try for this commond:
django-admin startproject mysite
instead of django-admin.py startproject mysite.

- 266
- 2
- 5
If everything is installed properly, when you open the command prompt, navigate to the desktop folder with
cd C:\Users\YOURNAME\Desktop
then type
django-admin startproject YOURPROJECTNAME
The project should appear on your desktop.
If you didn't navigate to your desktop folder and run the command there, your project could be placed in the windows\system32
folder on the C drive.
-
1
-
I used `django-admin startproject YOURPROJECTNAME .` ... note the trailing dot at the end. This prefents the nested folder structure. – MachineLearner Jan 01 '21 at 00:02
Try this instead! It also works inside virtualenv
python "C:\Python27\Scripts\django-admin.py" startproject test2

- 18,120
- 8
- 90
- 108
Go on to c:/python**/Scripts/ you must find django-admin.py
there that fixes your problem use the absolute path.
-
Yes, using absolute path works, but simply using the relative path does not work, even though the path to python scripts + path to django/bin are added to environment variable. – codingbbq Nov 18 '12 at 07:25
after years I have to answer this question because the answer is changed for WINDOWS now
python C:\Path\To\Virtualenv\Scripts\django-admin.exe startproject <project_name>
you can use .exe for windows in Scripts folder
-
Currently it is as in the answer above. It is worth adding that you do not need to be in the directory, e.g. D:\python_projects\my_project\env\Scripts. You can enter it in the directory D:\python_projects\my_project and it also works. – Olgierd Wiśniewski May 08 '23 at 10:37
I'm on a Mac and had a similar problem after installing with pip3. I reinstalled and it corrected the error. You can try going to the #django irc channel at irc.freenodes

- 120
- 2
- 9
Try out this way.
1> Look where your python is installed if cannot find it in C:/ Python().
$ python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'c:\\Python26\\python.exe'
>>> sys.exec_prefix
'c:\\Python26'
>>>
>>> print '\n'.join(sys.path)
c:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg
c:\Python26\lib\site-packages\nose-1.0.0-py2.6.egg
C:\Windows\system32\python26.zip
c:\Python26\DLLs
c:\Python26\lib
c:\Python26\lib\plat-win
c:\Python26\lib\lib-tk
c:\Python26
c:\Python26\lib\site-packages
c:\Python26\lib\site-packages\win32
c:\Python26\lib\site-packages\win32\lib
c:\Python26\lib\site-packages\Pythonwin
c:\Python26\lib\site-packages\wx-2.8-msw-unicode
2> After that move into Scripts folder. There you may find django-admin.py. Now copy full path of that file.
3>Now run this command
python path of the file startproject name of Project
eg. python C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\Scripts\django-admin.py startproject mysite
hope this will work.

- 1
Even I faced the same problem. I even tried adding the directory to Environmental variables but it was not working, so I had to use python -m django
for it, but it didn't satisfy me, so I did a tricky thing.
Instead of adding the directory to Environmental variables, I copied the installed package and pasted it to the first directory (default directory) in environmental variable and it started working.

- 1,498
- 2
- 13
- 19
I have a easy solution for this. normally download the django-admin file from the web the add it to the python\script folder then add the C:\python\script
to the environment variable then try the command i.e django-admin startproject

- 13
- 5
If you have pip installed in that environment you can always download the Django in the virtual environment and use it to start your project like I did instead of downloading it from web or changing environment variables.