简体   繁体   中英

manage.py keeps using django's blank settings.py instead of settings.py in the same folder manage.py is in

I am using Windows 8.1 and Python 2.7 and I have all the files set up (hopefully correctly) in a specific file path but whenever I run python manage.py runserver I keep getting this error.

PS C:\Users\AWelborn\.virtualenvs\truthabouttrees\truth-about-trees> python manage.py runserver
C:\Python27\lib\site-packages\mezzanine\utils\conf.py:59: UserWarning: TIME_ZONE setting is not set, using closest match
: America/Denver
  warn("TIME_ZONE setting is not set, using closest match: %s" % tz)
C:\Python27\lib\site-packages\mezzanine\utils\conf.py:92: UserWarning: mezzanine.pages.context_processors.page is requir
ed in the TEMPLATE_CONTEXT_PROCESSORS setting. Adding it now, but you should update settings.py to explicitly include it
.
  "explicitly include it." % cp)
Traceback (most recent call last):
  File "manage.py", line 29, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 279, in execute
    saved_locale = translation.get_language()
  File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 154, in get_language
    return _trans.get_language()
  File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 52, in __getattr__
    if settings.USE_I18N:
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 54, in __getattr__
    self._setup(name)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 49, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 151, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

But when I look into the settings.py in the specific file path where settings.py is, it has everything. The lines above seem to indicate that it is trying to use django's setting.py instead of the one that already was fixed up. I also tried to use python C:/myfilepathtothisspecificfile/manage.py runserver but the same error occurs.

UPDATED -- secret keys is set and nevercache key as well. This is what my manage.py looks like atm.

from __future__ import absolute_import, unicode_literals

import os
import sys


# Corrects some pathing issues in various contexts, such as cron jobs,
# and the project layout still being in Django 1.3 format.
from settings import PROJECT_ROOT, PROJECT_DIRNAME
os.chdir(PROJECT_ROOT)
sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_ROOT, "..")))


# Add the site ID CLI arg to the environment, which allows for the site
# used in any site related queries to be manually set for management
# commands.
for i, arg in enumerate(sys.argv):
    if arg.startswith("--site"):
        os.environ["MEZZANINE_SITE_ID"] = arg.split("=")[1]
        sys.argv.pop(i)


# Run Django.
if __name__ == "__main__":
    settings_module = "%s.settings" % PROJECT_DIRNAME
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

Am I supposed to update the line sys.path.insert(0, os.path.abspath(os.path.join(PROJECT_ROOT, ".."))) to my path to settings.py?

Setup DJANGO_SETTINGS_MODULE variable to settings in Control Panel | System | Advanced System Settings | Environment Variables

Or in your manage.py change

settings_module = "%s.settings" % PROJECT_DIRNAME

to

settings_module = "settings"

which does efficiently the same thing.

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