Skip to content Skip to sidebar Skip to footer

Django-admin Runserver Error

I set virtualenv for python 2.7 16% source Work/Django/env/bin/activate next create project django-admin startproject myproject create app cd myproject django-admin startapp cont

Solution 1:

If you look at what the manage.py script does (this script was created inside the myproject directory when you ran django-admin startproject myproject), it exports the environment variable DJANGO_SETTINGS_MODULE and then runs django-admin (well, it does it through django.core but it does pretty much that).

django-admin needs to know the python module of the settings for your project, and that information is present in that environment variable.


Therefore, inside the myproject directory, you shall either run:

python manage.py runserver

and the manage.py script will do the environment setup for you, or you can force django-admin to read the settings location from the command line:

django-admin runserver --pythonpath=. --settings="myproject.settings"

The --pythonpath switch is not needed if you included your project directory on the default pyhton path.

Solution 2:

mkdir djangoproject

cd djangoproject/

pip install virtualenv

virtualenv myvenv

pip freeze

which python

source myvenv/bin/activate

pip install django

pip freeze

django-admin startproject myproject

cd myproject/

python manage.py runserver

Your project will be start successfully

django-admin startapp myapp

Now, you need to make some settings related to the application you created. (settings.py & urls.py)

Post a Comment for "Django-admin Runserver Error"