70π
When that didnβt work for me, I tried python -m django startproject mysite
and it worked.
38π
Actually, if you use Ubuntu, itβs just django-admin
not django-admin.py
.
Resides in /usr/bin
Probably the same thing on Mac.
Youβre using a Windows tutorial.
It may also tell you
python manage.py runserver
and that is actually
python ./manage.py runserver
- [Django]-Get list item dynamically in django templates
- [Django]-Django ImportError: cannot import name 'render_to_response' from 'django.shortcuts'
- [Django]-Django β how to unit test a post request using request.FILES
22π
I tried as the method, it worked.
pip uninstall django
sudo pip install django
django-admin startproject example
It worked well.
- [Django]-Proper way to consume data from RESTFUL API in django
- [Django]-TransactionManagementError "You can't execute queries until the end of the 'atomic' block" while using signals, but only during Unit Testing
- [Django]-How to pass an array in Django to a template and use it with JavaScript
13π
Make sure you properly did the source bin/activate
command. If you skip that, or do it in a different terminal window, or close the window then re-open it, you wonβt be in the virtualenv and you wonβt have access to the django-admin.py
command in your environment.
- [Django]-Django templates β split string to array
- [Django]-Custom form validation
- [Django]-Mac OS X β EnvironmentError: mysql_config not found
13π
If youΒ΄re on Windows, hereΒ΄s what worked for me (using pylauncher):
$ py -m django startproject myproject
- [Django]-Set language within a django view
- [Django]-Django ORM β objects.filter() vs. objects.all().filter() β which one is preferred?
- [Django]-How to do math in a Django template?
8π
To solve this problem, you need:
-
Find the main folder of Django, and find the
django-admin.py
fileTypically, the file is in
<YOUR_DJANGO_FOLDER>/bin/django-admin.py
-
Create a link for this file
ln -s /bin/django-admin.py /usr/local/bin/django-admin
-
Type
django-admin
in your command to check if it works
- [Django]-Django, ImportError: cannot import name Celery, possible circular import?
- [Django]-Atomic increment of a counter in django
- [Django]-Gunicorn Connection in Use: ('0.0.0.0', 5000)
5π
For me this one worked
python3 -m django startproject mysite
Then it doesnβt tell you that it created file you must check by yourself in your home
hardrive/user/urhome
- [Django]-Django release 1.5: 'url' requires a non-empty first argument. The syntax changed in Django 1.5
- [Django]-Django queries β id vs pk
- [Django]-How to assign items inside a Model object with Django?
4π
As Timmy said above, it could just be that django-admin.py is not on your system path.
See here β https://code.djangoproject.com/wiki/InstallationPitfalls β for 3 possible causes with solutions.
- [Django]-How to set a Django model field's default value to a function call / callable (e.g., a date relative to the time of model object creation)
- [Django]-How can I tell the Django ORM to reverse the order of query results?
- [Django]-Django query get last n records
4π
I have used follwong command to install (/usr/local/bin) MAC OS
pip install django
django-admin startproject mysite
- [Django]-In Django β Model Inheritance β Does it allow you to override a parent model's attribute?
- [Django]-How to set ForeignKey in CreateView?
- [Django]-Django: Purpose of django.utils.functional.SimpleLazyObject?
4π
- [Django]-Error loading MySQLdb Module 'Did you install mysqlclient or MySQL-python?'
- [Django]-Storing an Integer Array in a Django Database
- [Django]-Redirect to Next after login in Django
- [Django]-Using window functions in an update statement
- [Django]-List_display β boolean icons for methods
- [Django]-Django import error β no module named django.conf.urls.defaults
2π
The following guide in official site https://code.djangoproject.com/wiki/InstallationPitfalls
First, you should find location of django-admin.py
by
which django-admin.py
Example: in my case
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py
You use sudo ln -s
to relocate django-admin-py
to /usr/local/bin
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py
after that change permission of the django-admin to be executable
sudo chmod +x /usr/local/bin/django-admin.py
Now you can use
django-admin.py startproject mysite
to create your django project
If you want to change django-admin.py
to django-admin
to look like more compact you can use
sudo mv /usr/local/bin/django-admin.py /usr/local/bin/django-admin
Hope this help for you !
- [Django]-Annotating a Sum results in None rather than zero
- [Django]-Django: Get an object form the DB, or 'None' if nothing matches
- [Django]-Django: show/log ORM sql calls from python shell
2π
This simply worked for me.
Install django on your virtualenv:
pip install django
And then run:
django-admin startproject myprojectname
- [Django]-Python/Django: log to console under runserver, log to file under Apache
- [Django]-Django ignores router when running tests?
- [Django]-Getting Site Matching Query Does Not Exist Error after creating django admin
2π
I was just having the same problem, I just did an upgrade and thatβs it, it worked, I hope this is useful for future problems in Linux:
pip install --upgrade django
- [Django]-Django's forms.Form vs forms.ModelForm
- [Django]-How to add multiple arguments to my custom template filter in a django template?
- [Django]-One app with many models vs. many apps with single model
2π
There may be a chance that your path is not correct. Ubuntu has a .local/bin folder which pip uses to install module binaries and you need it in your path to use django or any shell commands installed using pip.
- Open
~/.bashrc
or~/.zshrc
- Add the following line and save it
export PATH="/home/animesh/.local/bin:$PATH"
- restart the shell with
source ~/.zshrc
- [Django]-Where does pip install its packages?
- [Django]-RuntimeWarning: DateTimeField received a naive datetime
- [Django]-Use variable as dictionary key in Django template
1π
To windows users out there: I have faced this problem several times and here are the checkpoints:
When there is problem initiating a new project, make sure:
1) python is working in the command line (type in python and see if you get the console)
2) specify the full path of django-admin.py in the command
3) check django-admin.py is in the system path
4) cd the command line path to where you want the new project
Screenshot of what finally worked for me (only the last command):
https://flic.kr/p/r9LJ67
(stackoverflow doesnβt allow me to post pictures yet)
- [Django]-Cannot apply DjangoModelPermissions on a view that does not have `.queryset` property or overrides the `.get_queryset()` method
- [Django]-Django simple_tag and setting context variables
- [Django]-How do I migrate a model out of one django app and into a new one?
1π
If you come across command not found: django-admin.py
problem which means you donβt installed django frame work. You should install the framework using pip.
pip install django
After that look at the directory if the related script exist or not.
Look into C:\Python27\Scripts
folder to check for django-admin.py exist or not.
- [Django]-How to update fields in a model without creating a new record in django?
- [Django]-Django values_list vs values
- [Django]-Error "You're accessing the development server over HTTPS, but it only supports HTTP"
1π
if you install django by pip
- ensure you have installed django:
pip list or pip freeze
if there is django
then
- get location of django:
pip show django
if location is β/Users/xxxxx/Library/Python/2.7/lib/python/site-packagesβ then
- relocate django-admin-py to /usr/local/bin:
ln -s /Users/xxxxx/Library/Python/2.7/lib/python/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py
- [Django]-Django Rest Framework β Authentication credentials were not provided
- [Django]-Python + Django page redirect
- [Django]-How to run Django's test database only in memory?
1π
Get site-package path with Python:
import site; site.getsitepackages()
And run django-admin.py directly:
python (your-site-package-addresss)/django/bin/django-admin.py startproject hellodjango
On Mac: If this works you can go and add django-admin.py to your path using symlink:
sudo ln -s (your-site-package-addresss)/django/bin/django-admin.py /usr/local/bin/django-admin
(could be that you have to reopen terminal or reinstall django to get the symlink working)
- [Django]-Loop backwards using django template
- [Django]-Django Query Related Field Count
- [Django]-How do I create multiple model instances with Django Rest Framework?
1π
I changed my complete python path to desktop and tried and itβs working well for me
- [Django]-Troubleshooting Site Slowness on a Nginx + Gunicorn + Django Stack
- [Django]-Django Templating: how to access properties of the first item in a list
- [Django]-Django Reverse with arguments '()' and keyword arguments '{}' not found
- [Django]-Execute code when Django starts ONCE only?
- [Django]-How do you log server errors on django sites
- [Django]-Django no such table:
- [Django]-What is the difference between {% load staticfiles %} and {% load static %}
- [Django]-Need to convert a string to int in a django template
- [Django]-How to store a dictionary on a Django Model?
0π
Iβm running macOS and Iβm using pyenv instead of virtualenv. Iβm not sure if they behave similarly, but I was having the same problem in which django-admin.py was not found.
After a while Iβve noticed that I had a warning after installing django:
pyenv: cannot rehash: /Users/msvolenski/.pyenv/shims/.pyenv-shim exists
Once I deleted this file and ran pyenv rehash
it all started working perfectly.
Hope this helps!
- [Django]-Separating form input and model validation in Django?
- [Django]-Django optional URL parameters
- [Django]-Gunicorn autoreload on source change
0π
For Windows Users first search for django-admin, right click on the file that has been found and open file location and keep it open.
Using Windows Powershell, cd into the the folder where you want to create your django project
when your in the right folder write the full path of where django-admin is located in my case I am using Anaconda 3 so the file location is
C:\Users\Sen\Anaconda3\Scripts
so in Windows PowerShell type C:\Users\Sen\Anaconda3\Scripts\django-admin.py startproject [name of project]
hope this helps!
- [Django]-How can I avoid "Using selector: EpollSelector" log message in Django?
- [Django]-Get virtualenv's bin folder path from script
- [Django]-Can I use Socket.IO with Django?
0π
I had the same issue when migrating to AWS Beanstalk it was installed and everything but i noticed the alias was not working but when i called the entire thing path and all it worked so i just rebooted the boxes and it worked i think the alias list is not updated automatically after you install.
- [Django]-Models.py getting huge, what is the best way to break it up?
- [Django]-How to test "render to template" functions in django? (TDD)
- [Django]-Proper way to consume data from RESTFUL API in django
0π
It has to do with the PATH:
Put this in the .bash_profiel and the source it (for mac users only):
(change the location with the location of your installed python libraries)
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
- [Django]-How do I send empty response in Django without templates
- [Django]-Django: change the value of a field for all objects in a queryset
- [Django]-Django 1.5 custom User model error. "Manager isn't available; User has been swapped"
0π
If someone is facing the same problem, and is on MacOs, here is what I did, and it worked for me:
If youβve installed python directly from the official website, uninstall it, and install it once again using brew:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install python3
This will also install the pip3 for you, so you donβt have to install it by yourself.
- [Django]-Does django with mongodb make migrations a thing of the past?
- [Django]-How to add multiple arguments to my custom template filter in a django template?
- [Django]-Setting default value for Foreign Key attribute in Django
0π
I was facing the same issue.
The issue resolved after I upgraded the django version using
pip install --upgrade django
Then run
django-admin startproject mysite
Hope this helps!
- [Django]-Using Basic HTTP access authentication in Django testing framework
- [Django]-DatabaseError: current transaction is aborted, commands ignored until end of transaction block?
- [Django]-What is reverse()?
0π
There was a space in one of the names in the path to my project. I set up a new virtual environment in a new directory and did all the same things and it works.
Sometimes it is the simple thingsβ¦
- [Django]-Django: using <select multiple> and POST
- [Django]-Difference between different ways to create celery task
- [Django]-Variable subtraction in django templates
0π
Since youβre just starting out. It is very important to adopt best practices. You will face many dependency related issues with this approach of development. In this case it is always recommended to work with a virtual environment for each python project.
This will ensure fresh installation of project-specific dependencies that do not overlap with what the system you are running on already has.
If you have not already noticed, you will come across more issues such as python3 not working with earlier versions of django. pip will skip install as it checks and finds a version of django already installed. So this cannot be stressed enough, always use a virtual environment for local setups.
to do so:
- cd [your project path]
virtualenv venv
- you can active your environment by :
source ./venv/bin/active
- install your requirements packages with pip :
pip install -r
or pip install
you can also install your requirements modules without activate the environment
./venv/bin/pip install
- to run your python script use :
python <.py file>
and if you didnβt activate your env use :
./venv/bin/python <.py file>
- [Django]-Django database query: How to get object by id?
- [Django]-Django set range for integer model field as constraint
- [Django]-How to get Request.User in Django-Rest-Framework serializer?
0π
I take as reference this page and it tells you what to do very clearly.
https://realpython.com/django-setup/
Here are the steps in short if you donβt want to visit the site.
-
Set up a virtual environment in a folder that you created. I created in Desktop a folder named "python_project". Inside that folder run: python3 -m venv env in terminal.
-
Then activate the virtual environment with command: source env/bin/activate
-
Install django after activating virtual environment with this command: python -m pip install django
-
Pin your dependencies to make sure that youβre keeping track of which Django version you installed: python -m pip freeze > requirements.txt
-
Start a django project django-admin startproject
-
Then start a django app which should be inside first folder of the project so first change directory to then in terminal enter this command: python manage.py startapp
Then most probably you will see a scaffolding like this:
setup/
β
βββ example/
β β
β βββ migrations/
β β βββ __init__.py
β β
β βββ __init__.py
β βββ admin.py
β βββ apps.py
β βββ models.py
β βββ tests.py
β βββ views.py
β
βββ setup/
β βββ __init__.py
β βββ asgi.py
β βββ settings.py
β βββ urls.py
β βββ wsgi.py
β
βββ manage.py
- [Django]-Difference between different ways to create celery task
- [Django]-Overriding AppConfig.ready()
- [Django]-How to refer to static files in my css files?