简体   繁体   中英

“python manage.py runserver” vs “django-admin runserver”

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM