Python django:django.core.exceptions.impropertlyconfigured:SECRET\u密钥设置不能为空

Python django:django.core.exceptions.impropertlyconfigured:SECRET\u密钥设置不能为空,python,django,Python,Django,我正试图在ubuntu服务器上使用 /opt$ sudo python peace/src/manage.py runserver 我收到的错误为“django.core.exceptions.impropertlyconfigured:密钥设置不能为空。” 我能够在我的开发环境eclipse IDE中在windows中启动相同的应用程序 我的文件夹结构>/opt/peace/src/manage.py 设置文件夹结构>/opt/peace/src/peace/settings/ manage

我正试图在ubuntu服务器上使用

/opt$ sudo python peace/src/manage.py runserver
我收到的错误为“
django.core.exceptions.impropertlyconfigured:密钥设置不能为空。

我能够在我的开发环境eclipse IDE中在windows中启动相同的应用程序

我的文件夹结构>/opt/peace/src/manage.py

设置文件夹结构>
/opt/peace/src/peace/settings/

manage.py:-

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "peace.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
请各位指教,

完整错误日志

ubuntu@ip-172-31-19-246:/opt$ sudo python peace/src/manage.py runserver
Traceback (most recent call last):
  File "peace/src/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 190, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 40, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 14, in <module>
    from django.db.migrations.executor import MigrationExecutor
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 6, in <module>
    from .loader import MigrationLoader
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/loader.py", line 10, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 9, in <module>
    class MigrationRecorder(object):
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
    class Migration(models.Model):
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/recorder.py", line 24, in Migration
    app = models.CharField(max_length=255)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 1081, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py", line 161, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 44, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 113, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
local.env

DEBUG=True
# syntax: DATABASE_URL=psql://username:password@127.0.0.1:8458/database
DATABASE_URL=sqlite:///db.sqlite3
SECRET_KEY="v(jkz$=0+nj38pmf%iqddjok47zcgt+h%9*6ehn=2vbbj3%vj&"

您似乎没有正确地引用
DJANGO\u设置\u模块。在manage.py中,您只指向
peace.settings
,但可能需要指向其中的一个模块,例如,
peace.settings.base

您的
settings.py
文件是什么样的?它是否包含一个
SECRET\u KEY
?它需要
SECRET\u KEY=“什么……什么都可以!!”
@JoranBeasley,@Leistungsagfall。是在设置文件中设置了密钥。编辑的问题,包括设置信息,我也能够在我的开发环境中启动相同的应用程序在windows中的eclipse IDE。!!为什么要通过
sudo
运行服务器?这是个坏主意,甚至可能是你问题的原因。
DEBUG=True
# syntax: DATABASE_URL=psql://username:password@127.0.0.1:8458/database
DATABASE_URL=sqlite:///db.sqlite3
SECRET_KEY="v(jkz$=0+nj38pmf%iqddjok47zcgt+h%9*6ehn=2vbbj3%vj&"