63๐
Working !!
If you are using window then first of all
create virtual environment
python -m venv venv
Then activate that environment
venv\Scripts\activate
Then install Django in that environment
pip install django
Then create django project named mysite
django-admin startproject mysite
20๐
I have the same problem because i have installed Django Manually. The solution for resolve :
- Install Python https://www.python.org/downloads/ (if not installed)
- Verify your Path : https://stackoverflow.com/a/17836439 Itโs very important or the next no work.
- Install setuptool : Download the .py file here : https://bootstrap.pypa.io/ez_setup.py and execute this with python.
- Install PIP with this command :
easy_install pip
- Clean Django :
pip uninstall django
- install Django :
pip install django
- Execut
django-admin.py startproject mysite
and enjoy.
If not OK, test django-admin-script.py startproject mysite
. If is ok, your django installation is wrong.
Sorry for my bad english, iโm french ๐
- [Django]-Direct assignment to the forward side of a many-to-many set is prohibited. Use emails_for_help.set() instead
- [Django]-Django REST Framework: adding additional field to ModelSerializer
- [Django]-How can I get the URL (with protocol and domain) in Django (without request)?
16๐
Find the folder where django-admin.py is located. Then go to Control Panel > System > Advanced System Settings > Environment Variables . In the User Variables and/or System Variables, search for an entry called PATH. Modify it by adding the folder you found earlier, use the other entries as guidance, basically just make sure theyโre separated by ;
. If you have done all these steps, but are still in the same cmd prompt that you were using before doing them, close it and open a new one so it picks up on your changes.
- [Django]-Django long running asynchronous tasks with threads/processing
- [Django]-Django: Add non_field_error from view?
- [Django]-Django: How to save data to ManyToManyField?
9๐
I have tried all of the mentioned things however I was still unable to create a project using django-admin startapp appname
. So I used python -m django startproject appname
instead and was able to create the proejct
- [Django]-Django migrations โ workflow with multiple dev branches
- [Django]-Django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured
- [Django]-Unable to get results from Google text to speech api while streaming audio from web
- [Django]-Django admin sort foreign key field list
- [Django]-Django: Grab a set of objects from ID list (and sort by timestamp)
- [Django]-Can I use Django F() objects with string concatenation?
7๐
For windows, the โdjango-adminโ you need to create a project is an .exe file not a .py file and it is present at the following location:
C:\Python27\Scripts
so you have to add this location to your path.
- [Django]-How to aggregate (min/max etc.) over Django JSONField data?
- [Django]-Select DISTINCT individual columns in django?
- [Django]-What is the clean way to unittest FileField in django?
7๐
-
After running
pip install django
wait for the setup to finish and
present you with a warning. -
From the warning copy the path of where django is installed. In my
case it is
C:\Users\USERNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8\LocalCache\local-packages\Python38\Scripts
-
Add that to
PATH
in environment variables and restart cmd or shell.
- [Django]-Django: Group by date (day, month, year)
- [Django]-How can I trigger a 500 error in Django?
- [Django]-What base_name parameter do I need in my route to make this Django API work?
- [Django]-Python/Django: log to console under runserver, log to file under Apache
- [Django]-Django Admin โ Overriding the widget of a custom form field
- [Django]-Django testing: Test the initial value of a form field
3๐
If it did not work for you even if you tried the command :
django-admin startproject mysite
Hereโs what worked for me:
- Uninstall django
pip uninstall django
- Add the below path to the PATH variables-
C:\Users\System_Name\AppData\Roaming\Python\Python39\Scripts
Note: In the above path, System_Name refers to the name of your laptop/pc.
- Install django again
pip install django
You can check the version of django using django-admin โversion
- [Django]-How to change empty_label for modelForm choice field?
- [Django]-How do I create a superuser account in Django 1.9.6
- [Django]-UnicodeEncodeError: 'ascii' codec can't encode character
1๐
You need to install django. It seems you have just downloaded it and expanded the archive.
- Install setuptools
- Install pip
- Open a command prompt and then type
pip install -U django
(or, you can download the windows installer).
Once you have done the above steps, you need to make sure C:\Python27\Scripts
is in your PATH
; otherwise the commands will not work.
To set PATH
, go to Environment Variables
from My Computer
(right click and then go to Manage, then on the left, Advanced Settings).
Finally, youโll need to run python django-admin.py
and not django-admin.py
- [Django]-Django :How to integrate Django Rest framework in an existing application?
- [Django]-Django-debug-toolbar not showing up
- [Django]-Sorting related items in a Django template
1๐
this one workked for me
python 2.6.6
django 1.6.11
python C:\Python26\Scripts\django-admin.py startproject myapplication
- [Django]-Make boolean values editable in list_display?
- [Django]-Renaming an app with Django and South
- [Django]-Django return redirect() with parameters
- [Django]-Django Rest Framework Postman Token Authentication
- [Django]-Django South โ table already exists
- [Django]-How to call super of enclosing class in a mixin in Python?
1๐
Add the following address in the system path
C:\Users\{username}\AppData\Roaming\Python\Python39\Scripts
{username} : enter your username
- [Django]-Get user profile in django
- [Django]-Writing test cases for django models
- [Django]-Django "You have unapplied migrations". Which ones?
- [Django]-How Can I Disable Authentication in Django REST Framework
- [Django]-How to limit columns returned by Django query?
- [Django]-Django Datefield to Unix timestamp
1๐
I faced the same problem and tried many ways. Solved my problem by following these steps
Python installation manually
in my cmd
pip install Django
pip install djangorestframework
pip install django-cors-headers
pip install virtualenvwrapper-win
Windows+r
sysdm.cpl
In Advanced Option, Environment Variables> In user variable edit
path
C:\Users\mushf\AppData\Roaming\Python\Python310
C:\Users\mushf\AppData\Roaming\Python\Python310\Scripts
In System Variable> Edit
path
C:\Program Files\Python310\Scripts\
C:\Program Files\Python310\
After that create my project folder in the desired location:
django-admin start project ProjectName
My preferable IDE is pycharm
- [Django]-How do I use django rest framework to send a file in response?
- [Django]-Strange PostgreSQL "value too long for type character varying(500)"
- [Django]-Django content-type : how do I get an object?
1๐
Instructions for Windows
You must have pip on your machine.
Open Visual Studio and open the project folder.
Open terminal from VS, Terminal tab. Go to the project directory.
pip3 install virtualenvwrapper
This must be done only the very first time you are setting up your environment.
Then run:
python -m venv env
Installs the needed files for running a virtual environment. You should see a folder added now. Create a virtual environment. Now activate it (i.e. start working in the virtual environment):
activate environment env\Scripts\activate
if activate doesnโt work use this
env\Scripts\activate
Install Django in a virtual environment. If you want a specific version run:
pip install django==3.0.3
For the latest version just run:
pip install Django
To check the existing version:
pip freeze
To create a new project:
django-admin startproject simplesite
cd simplesite
python manage.py startapp helloworld
will create a new application in the project with a folder "helloworld"
python manage.py runserver 127.0.0.1:8080
Open in your browser http://localhost:8080 to test the running server.
Ctrl+C to stop the server.
- [Django]-Understanding Django-LDAP authentication
- [Django]-Can a generic.GenericForeignKey() field be Null?
- [Django]-Query for top x elements in Django
0๐
copy the Django-admin.exe file into the folder you are using. the file can be found at python/python(version)/scripts. when you finish a folder should pop up in the name of your file
- [Django]-How to annotate Count with a condition in a Django queryset
- [Django]-Django query get last n records
- [Django]-Updating a Haystack search index with Django + Celery
0๐
Just copy the Django admin.py file which is present actually where you have installed python in C:\program files\Python or in my case it was located at administrator\appdata\local\programs\python you can check yours and just copy the file that is Django admin from script folder to your newly created folder
- [Django]-Custom Filter in Django Admin on Django 1.3 or below
- [Django]-Django Rest Framework: turn on pagination on a ViewSet (like ModelViewSet pagination)
- [Django]-How to generate urls in django
0๐
I needed to update my System Environment Variable path
so this answer helped me:
- [Django]-How can I find the union of two Django querysets?
- [Django]-Django-admin: Add extra row with totals
- [Django]-UUID as default value in Django model
0๐
You will have to activate the environment (env) before you run the command:
django-admin startproject myapp
I had the same problem.
- [Django]-Why django urls end with a slash?
- [Django]-Difference between User.objects.create_user() vs User.objects.create() vs User().save() in django
- [Django]-Find all references to an object in python
0๐
For Windows user:
Step 1: Open cmd in the project directory
Step 2: Run this in cmd : python -c "import django; print(django.__path__)"
Step 3: Go to the path and copy django-admin.exe to the current project directory
Step 4: Run this in cmd : django-admin startproject DEMO
Happy Learning,
Thank you
- [Django]-How can I apply a filter to a nested resource in Django REST framework?
- [Django]-What's the differences between has_object_permission and has_permission?
- [Django]-Error: No module named psycopg2.extensions
0๐
Before you run django-admin.py startproject mysite
1) You need to create a virtual enviroment on the folder that you want to store your project
so run pipenv install django==2.1
(if you dont have pipenv installed run
pip install --user pipenv
)
2) To run this virtual enviroment run pipenv shell
3)And finaly django-admin.py startproject mysite
Hope this works
- [Django]-Do I need Nginx with Gunicorn if I am not serving any static content?
- [Django]-Django template if or statement
- [Django]-How to add an annotation on distinct items?
0๐
In my case I made a mistake installing django in a wide system manner and then it created /usr/local/bin/django-admin
I uninstalled django through pip but it doesnโt remove those files then when you type the command it tries to invoke that file but as it says the module django is not present.
Just remove those orphans files (use sudo if needed)
sudo rm /usr/local/bin/django-admin
sudo rm /usr/local/bin/django-admin.py
and try again (with your virtualenv activated) and it should takes the right module and works as usual!
- [Django]-Accessing function as attribute in a Python class
- [Django]-JSP template inheritance
- [Django]-How to Copy/Clone a Virtual Environment from Server to Local Machine
0๐
This is my solution:
step-1 --add environmental path
C:\Users\DELL\AppData\Local\Programs\Python\Python38
C:\Users\DELL\AppData\Local\Programs\Python\Python38\Scripts
step-2 pip install django
step-3 --run command in specific folder
django-admin.py startproject mysite
- [Django]-Returning pure Django form errors in JSON
- [Django]-Django staticfiles app help
- [Django]-Django โ why is the request.POST object immutable?
0๐
For me, a simple fix was reinstalling python. It turns out I didnโt select add to path, when installing python the first time, and that is crucial.
- [Django]-Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
- [Django]-Uncaught TypeError: Cannot read property 'ownerDocument' of undefined
- [Django]-Renaming an app with Django and South
0๐
if you are using windows then goto (search)"advanced system settings/Environment veriables/New path" and add path of your python packeges folder, in my case its "C:\python38\Lib\site-packages".
may be you have other path of site-packages folder.
- [Django]-Radio buttons in django Forms
- [Django]-AttributeError: module Django.contrib.auth.views has no attribute
- [Django]-How do you perform Django database migrations when using Docker-Compose?
0๐
If you are using Pycharm then after creating New project just go to the fileโ>settingโ>projectโ>serch Djangoโ>install Django then go to the terminal type django-admin startproject name(whichever you want) press enter
- [Django]-Removing 'Sites' from Django admin page
- [Django]-How to upgrade django?
- [Django]-Using AD as authentication for Django
- [Django]-How to check DEBUG true/false in django template โ exactly in layout.html
- [Django]-Where did Django form wizard go in django 1.8?
- [Django]-Django humanize outside of template?
0๐
If you had this error occur on windows after installing django
using pip that has the message along the following lines:
could not install packages due to an OSError: [WinError 2] The system
cannot find the file specified: โc:\python39\Scripts\sqlformat.exeโ
-> โc:\python39\Scripts\sqlformat.exe.deletemeโ
Which in turn causes the same problem as the question stated. A working solution is to clean installing django
which you can do by using pip uninstall django
, and then reinstalling it by running the install command like this: pip install --user django
.
If no other warnings or errors occur, then it should be fixed. In case a warning sating that the django-admin.exe
file is located at some location that needs to be added to the path variable, you can copy that path and add it to the path variable under your environment variable settings.
Quick fix guide:
- Uninstall django:
pip uninstall django
. - Reinstall django:
pip install --user django
. - If a warning occurs containing a path continue to step 4 otherwise it should be fixed, and you may skip to the bottom.
- Copy the path that should be added to the PATH environment variable.(the one specified in the warning)
- Click on the start menu button.
- Search for
Control Panel
and click on it. - Change the
View by:
option toLarge icons
. - Click on the
System
item. - Click on the
Advance system settings
button. - The
System Properties
window will open, proceed to click on theEnvironment Variables...
button at the bottom right. - A new window will open displaying your Environment Variables, on the first gird select the row with the name of
PATH
orPath
orpath
under theVariable
column. - Then click the
Edit
button just below the grid. - A new window will open, proceed to click on the
New
button and paste the path you copied earlier. - After pasting press the
Enter
key and proceed to click on theOK
button. - Once the window closes and youโre back in the
Environment Variables
window proceed to do steps 11 to 14 again only with the grid at the bottom(inside the System Variables group). - Once all these steps were followed you may click on the
OK
button in theEnvironment Variables
window and close out of all the other windows that are still open after you followed these steps. - Close your
CMD
window and open a new one (this allows it to recognize the changes you made to your environment variables).
After following these steps, you should be able to continue with what you were doing without having any other difficulties further regarding Django
- [Django]-Is there a function for generating settings.SECRET_KEY in django?
- [Django]-How can I turn Django Model objects into a dictionary and still have their foreign keys?
- [Django]-Python/Django: how to assert that unit test result contains a certain string?
0๐
I wasnโt getting the django-admin to run even after an hour of configuring PATH etc. That was all completely useless.
What actually WORKED was running the windows terminal (cmd) as admin and then doing "pip install django". Be sure to first uninstall it though using "pip uninstall django", so that you get a clean installation.
Now django-admin runs perfect on cmd with or without admin rights.
- [Django]-RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
- [Django]-How to filter objects for count annotation in Django?
- [Django]-Django REST Framework ModelSerializer get_or_create functionality
0๐
Try Creating a python virtual environment in the given folder using
python -m venv venv
then activate the virtual environment using
venv\Scripts\activate
now use the pip command to install django
pip install django
- [Django]-Manage.py runserver
- [Django]-How do you filter a nested serializer in Django Rest Framework?
- [Django]-What is dispatch used for in django?
0๐
Iโve faced the same problem. Open Terminal. Even if you have Django already installed in your project follow the below steps:
Type โ python -m django --version
If it displays a version number start from Step 1 if not start from Step 2.
-
pip uninstall Django
(A confirmation should pop-up requesting you to type Y/N. Go with Y) -
pip install Django
(Django should be installed without any issues) -
python -m django --version
(It should display the version number) -
djangoadmin
(This should display the list of available commands)
If step 4 works for you go ahead and enter django-admin startproject <your project name>
. Please replace with your project name.
- [Django]-Annotate a sum of two fields multiplied
- [Django]-Django content types โ how to get model class of content type to create a instance?
- [Django]-Returning pure Django form errors in JSON