Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"python manage.py runserver" vs "django-admin runserver"

Tags:

python

django

I have an app, Scaffold, installed, that runs perfectly when I use python manage.py runserver but when I try to start it using django-admin, it fails;

You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

I try calling it with django-admin migrate --settings=scaffold.settings And I get; ImportError: No module named scaffold.settings

I've tried multiple things, googled around, but can't seem to figure out what I need to change. The settings.py file is in the directory ..\scaffold but I am no longer certain that is the one I need to use.

like image 549
Eloque Avatar asked Aug 25 '15 08:08

Eloque


1 Answers

You should be using manage.py unless have a specific reason for not wanting project-specific configuration. According to the docs

manage.py is automatically created in each Django project. manage.py is a thin wrapper around django-admin that takes care of several things for you before delegating to django-admin:

  • It puts your project’s package on sys.path.
  • It sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s settings.py file.
  • It calls django.setup() to initialize various internals of Django.
like image 65
scytale Avatar answered Sep 30 '22 12:09

scytale