58π
It sounds like you do not have django installed. You should check the directory produced by this command:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
To see if you have the django packages in there.
If thereβs no django folder inside of site-packages, then you do not have django installed (at least for that version of python).
It is possible you have more than one version of python installed and django is inside of another version. You can find out all the versions of python if you type python
and then press TAB. Here are all the different pythonβs I have.
$python
python python2-config python2.6 python2.7-config pythonw2.5
python-config python2.5 python2.6-config pythonw pythonw2.6
python2 python2.5-config python2.7 pythonw2 pythonw2.7
You can do the above command for each version of python and look inside the site-packages directory of each to see if any of them have django installed. For example:
python2.5 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
python2.6 -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
If you happen to find django inside of say python2.6, try your original command with
python2.6 manage.py ...
- [Django]-Separating form input and model validation in Django?
- [Django]-How to combine multiple QuerySets in Django?
- [Django]-Format numbers in django templates
30π
I got the same error and I fixed it in this manner:
I had to activate my virtual environment using the following command
source python2.7/bin/activate
- [Django]-Determine variable type within django template
- [Django]-Django DoesNotExist
- [Django]-How to select a record and update it, with a single queryset in Django?
22π
Most probably in your manage.py
the first line starts with !/usr/bin/python
which means you are using the system global python rather than the one in your virtual environment.
so replace
/usr/bin/python
with
~/projectpath/venv/bin/python
and you should be good.
- [Django]-How to create an object for a Django model with a many to many field?
- [Django]-Django β Rotating File Handler stuck when file is equal to maxBytes
- [Django]-How can I call a custom Django manage.py command directly from a test driver?
14π
well, I faced the same error today after installing virtualenv and django. For me it was that I had used sudo (sudo pip install django) for installing django, and I was trying to run the manage.py runserver without sudo. I just added sudo and it worked. π
- [Django]-Modulus % in Django template
- [Django]-Django: Multiple forms possible when using FormView?
- [Django]-Django models: Only permit one entry in a model?
10π
Are you using a Virtual Environment with Virtual Wrapper? Are you on a Mac?
If so try this:
Enter the following into your command line to start up the virtual environment and then work on it
1.)
source virtualenvwrapper.sh
or
source /usr/local/bin/virtualenvwrapper.sh
2.)
workon [environment name]
Note (from a newbie) β do not put brackets around your environment name
- [Django]-How can I list urlpatterns (endpoints) on Django?
- [Django]-How do I run tests for all my Django apps only?
- [Django]-How exactly do Django content types work?
7π
I am having the same problem while running the command-
python manage.py startapp < app_name >
but problem with me is that i was running that command out of virtual environment.So just activate your virtual environment first and run the command again β
- [Django]-How can I filter a date of a DateTimeField in Django?
- [Django]-Get model's fields in Django
- [Django]-How to get GET request values in Django?
6π
The problem occurs when django isnβt installed on your computer. You also get this error because the django.core.management module is missing.
To solve this issue we have to install django using pip. Open a command line prompt -> cmd(on windows) and enter the following command:
pip install django
This command will install django on your computer. So consider installing pip first. Hereβs how to install pip on a Windows machine
- [Django]-How do I do an OR filter in a Django query?
- [Django]-Django: Arbitrary number of unnamed urls.py parameters
- [Django]-Django Model() vs Model.objects.create()
6π
I experience the same thing and this is what I do.
First my installation of
pip install -r requirements.txt
is not on my active environment. So I did is activate my environment then run again the
pip install -r requirements.txt
- [Django]-Is this the right way to do dependency injection in Django?
- [Django]-How can I disable logging while running unit tests in Python Django?
- [Django]-Can't install via pip because of egg_info error
4π
Okay so it goes like this:
You have created a virtual environment and django module belongs to that environment only.Since virtualenv isolates itself from everything else,hence you are seeing this.
go through this for further assistance:
1.You can switch to the directory where your virtual environment is stored and then run the django module.
2.Alternatively you can install django globally to your python->site-packages by either running pip or easy_install
Command using pip: pip install django
then do this:
import django print (django.get_version()) (depending on which version of python you use.This for python 3+ series)
and then you can run this: python manage.py runserver and check on your web browser by typing :localhost:8000 and you should see django powered page.
Hope this helps.
- [Django]-Define css class in django Forms
- [Django]-Django REST Framework : "This field is required." with required=False and unique_together
- [Django]-Django admin file upload with current model id
3π
In case this is helpful to others⦠I had this issue because my virtualenv defaulted to python2.7 and I was calling Django using Python3 while using Ubuntu.
to check which python my virtualenv was using:
$ which python3
>> /usr/bin/python3
created new virtualenv with python3 specified (using virtualenv wrapper https://virtualenvwrapper.readthedocs.org/en/latest/):
$ mkvirtualenv --python=/usr/bin/python3 ENV_NAME
the python path should now point to the virtualenv python:
$ which python3
>> /home/user/.virtualenvs/ENV_NAME/bin/python3
- [Django]-Timestamp fields in django
- [Django]-Django project models.py versus app models.py
- [Django]-A Better Django Admin ManyToMany Field Widget
2π
This also happens if you change the directory structure of your python project (I did this, and then puzzled over the change in behavior). If you do so, youβll need to change a line in your /bin/activate file. So, say your project was at
/User/me/CodeProjects/coolApp/
and your activate file is at
/User/me/CodeProjects/coolApp/venv/bin/activate
when you set up your project, then you changed your project to
/User/me/CodeProjects/v1-coolApp/
or something. You would then need to open
/User/me/CodeProjects/v1-coolApp/venv/bin/activate
find the line where it says
VIRTUAL_ENV="/User/me/CodeProjects/coolApp"
export VIRTUAL_ENV
and change it to
VIRTUAL_ENV="/User/me/CodeProjects/v1-coolApp"
before reactivating
- [Django]-Django. A good tutorial for Class Based Views
- [Django]-How to add custom field in ModelSerializer?
- [Django]-CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False
2π
In my case, I am using Ubuntu. The problem can be that I donβt have the permission to write to that folder as a normal user. You can simply add the sudo
before your command and it should work perfectly. In my case sudo python manage.py syncdb
.
- [Django]-Django connection to PostgreSQL: "Peer authentication failed"
- [Django]-Change a form value before validation in Django form
- [Django]-Unique fields that allow nulls in Django
2π
I had the same issue and the reason I was getting this message was because I was doing βmanage.py runserverβ whereas doing βpython manage.py runserverβ fixed it.
- [Django]-Django Cannot set values on a ManyToManyField which specifies an intermediary model. Use Manager instead
- [Django]-How to write setup.py to include a Git repository as a dependency
- [Django]-Django Forms: if not valid, show form with error message
2π
My case I used pyCharm 5 on mac. I also had this problem and after running this command my problem was solved
sudo pip install django --upgrade
- [Django]-How to solve "Page not found (404)" error in Django?
- [Django]-Modulus % in Django template
- [Django]-What is the purpose of adding to INSTALLED_APPS in Django?
2π
I had the same problem and following worked good, you should navigate main folder in your project than type:
source bin/activate
- [Django]-Add inline model to django admin site
- [Django]-Django Rest Framework with ChoiceField
- [Django]-Token Authentication for RESTful API: should the token be periodically changed?
1π
had the same problem.run command βpython manage.py migrateβ as root. works fine with root access (sudo python manage.py migrate )
- [Django]-AccessDenied when calling the CreateMultipartUpload operation in Django using django-storages and boto3
- [Django]-Pagination in Django-Rest-Framework using API-View
- [Django]-Django admin TabularInline β is there a good way of adding a custom html column?
1π
You can try it like so : python3 manage.py migrate
(make sur to be in the src/
directory)
You can also try with pip install -r requirements.txt
(make sur you see the requirements.txt
file when you type ls
after the migrate
If after all it still wonβt work try pip install django
Hope it helps
- [Django]-Django: using more than one database with inspectdb?
- [Django]-Rendering a template variable as HTML
- [Django]-What is the difference render() and redirect() in Django?
0π
I got the same problem trying to use the python manage.py runserver. In my case I just use sudo su. Use the terminal as a root and try it again an it works partially. So I use python manage.py migrate comand and it fix it.
- [Django]-How to completely dump the data for Django-CMS
- [Django]-Django dynamic model fields
- [Django]-Django filter queryset __in for *every* item in list
0π
You must choose your Project first before running the server , type this
workon your_project_name
then
python manage.py runserver
- [Django]-Django proxy model and ForeignKey
- [Django]-Django count RawQuerySet
- [Django]-Django admin make a field read-only when modifying obj but required when adding new obj
0π
It is because of virtual enviornment configuration. You need to work on your virtual enviornmnet of Python. You should try on your command promt with,
workon virtual_enviornment_name
- [Django]-Django F() division β How to avoid rounding off
- [Django]-Trying to migrate in Django 1.9 β strange SQL error "django.db.utils.OperationalError: near ")": syntax error"
- [Django]-UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 2: ordinal not in range(128)
0π
Run following command
python3 manage.py runserver
Instead of
python manage.py runserver
- [Django]-Django can' t load Module 'debug_toolbar': No module named 'debug_toolbar'
- [Django]-How to use Python type hints with Django QuerySet?
- [Django]-Django 1.8 KeyError: 'manager' on relationship
-1π
File and Directory ownership conflict will cause issues here. Make sure the ownership of the directories and files under the project are to the current user. (You can change them using the chown command with the -R option.) Try rerunning the command: this solved the problem for me when running through the βFirst Django Appβ sample:
python manage.py startapp polls
- [Django]-Django REST framework: non-model serializer
- [Django]-Differences between STATICFILES_DIR, STATIC_ROOT and MEDIA_ROOT
- [Django]-Django: remove a filter condition from a queryset