Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"SECRET_KEY setting must not be empty" #1

Open
jacksorjacksor opened this issue Aug 25, 2015 · 10 comments
Open

"SECRET_KEY setting must not be empty" #1

jacksorjacksor opened this issue Aug 25, 2015 · 10 comments

Comments

@jacksorjacksor
Copy link

Hey there!

I just tried downloading and running this but was met with the below exception:

Traceback (most recent call last):
File "manage.py", line 28, in
execute_from_command_line(sys.argv)
File "/Users/majora/venv/lib/python2.7/site-packages/django/core/management/init.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/majora/venv/lib/python2.7/site-packages/django/core/management/init.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/majora/venv/lib/python2.7/site-packages/django/core/management/init.py", line 190, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/majora/venv/lib/python2.7/site-packages/django/core/management/init.py", line 40, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/Users/majora/venv/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 14, in
from django.db.migrations.executor import MigrationExecutor
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/migrations/executor.py", line 6, in
from .loader import MigrationLoader
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 10, in
from django.db.migrations.recorder import MigrationRecorder
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 9, in
class MigrationRecorder(object):
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
class Migration(models.Model):
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 24, in Migration
app = models.CharField(max_length=255)
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/models/fields/init.py", line 1081, in init
super(CharField, self).init(_args, *_kwargs)
File "/Users/majora/venv/lib/python2.7/site-packages/django/db/models/fields/init.py", line 161, in init
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "/Users/majora/venv/lib/python2.7/site-packages/django/conf/init.py", line 48, in getattr
self._setup(name)
File "/Users/majora/venv/lib/python2.7/site-packages/django/conf/init.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/Users/majora/venv/lib/python2.7/site-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.

Any thoughts of where this might be coming from? I'm very new to Mezzanine so would appreciate any help.

Cheers!

Rich

@rikdeakin
Copy link

Hi,

I'm also new to Django/Mezzanine and have also got the same error.

This is what I did:

  • Started a new env.
  • Copied your project files in to the env's project folder.
  • pip install -r requirements.txt
  • Edited settings.py
  • Tried to run python manage.py syncdb --migrate which gave the following error:
Traceback (most recent call last):
  File "manage.py", line 28, in <module>
    execute_from_command_line(sys.argv)
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 75, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 9, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal, emit_pre_sync_signal
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/core/management/sql.py", line 9, in <module>
    from django.db import models
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/__init__.py", line 5, in <module>
    from django.db.models.query import Q
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/query.py", line 17, in <module>
    from django.db.models.deletion import Collector
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/deletion.py", line 4, in <module>
    from django.db.models import signals, sql
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/sql/__init__.py", line 4, in <module>
    from django.db.models.sql.subqueries import *
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/sql/subqueries.py", line 12, in <module>
    from django.db.models.sql.query import Query
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 22, in <module>
    from django.db.models.sql import aggregates as base_aggregates_module
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/sql/aggregates.py", line 9, in <module>
    ordinal_aggregate_field = IntegerField()
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 116, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/rik/.virtualenvs/wg/local/lib/python2.7/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.

I would be super grateful if someone could let me know if I'm missing something here. Is this the proper way to install/run someone else's project?

All the best,
~ Rik

@kfn8dkodemonkey
Copy link

Soooo what so we do here? I would like to look at the templates however need to set KEY!!

@arjunmahishi
Copy link

I got the same problem..

@tiwiex
Copy link

tiwiex commented Dec 30, 2016

Same problem here. I see this is ongoing. Helllllpppp somebody.

@tiwiex
Copy link

tiwiex commented Dec 30, 2016

I just solved it.

  1. create your environment/ source myenv/bin/activate
  2. install from the requirement.txt with "pip2.7 install -r requirements.txt" from requirements directory (i think python 3.5 is too high)
  3. Generate a key online for django from http://www.miniwebtool.com/django-secret-key-generator/ then input in the settings.py as ( SECRET_KEY = "yj6o@&vrar6^l1u68!bxumj@xr4&5)zzk!h1qw&63^&@2d3w@#")
  4. edit the DATABASE SECTION in settings.
    ENGINE: django.db.backends.sqlite3 (append sqlite3)
    NAME: "dev.db" (or any name you like)
  5. Enable DEBUG = True (in settings.py) to see detailed debugs
  6. run python2.7 manage.py createdb --noinput
  7. run python2.7 manage.py changepassword admin
  8. Enter new password
  9. run python2.7 manage.py runserver
    you can shoot me a mail if you get stuck. Seems to require some experience setting up django.

@benlaoyao
Copy link

Hi!
Got through this stage, got an additional compatibility issue (solved), but I can't understand what is going wrong on the creation of the database. Apparently an issue with the template loader. Any help much appreciated.
`Traceback (most recent call last):
File "D:\Gdrive\website\Mezza\web00\lib\site-packages\django\template\base.py", line 1333, in import_library
mod = import_module(taglib_module)
File "D:\Gdrive\website\Mezza\web00\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 978, in _gcd_import
File "", line 961, in _find_and_load
File "", line 950, in _find_and_load_unlocked
File "", line 655, in _load_unlocked
File "", line 678, in exec_module
File "", line 205, in _call_with_frames_removed
File "D:\Gdrive\website\Mezza\web00\lib\site-packages\mezzanine\template\loader_tags.py", line 8, in
from django.template.loader import find_template_loader
ImportError: cannot import name 'find_template_loader'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Gdrive\website\Mezza\web00\mezzthemes\manage.py", line 10, in
from settings import PROJECT_ROOT, PROJECT_DIRNAME
File "D:\Gdrive\website\Mezza\web00\mezzthemes\settings.py", line 371, in
set_dynamic_settings(globals())
File "D:\Gdrive\website\Mezza\web00\lib\site-packages\mezzanine\utils\conf.py", line 49, in set_dynamic_settings
add_to_builtins("mezzanine.template.loader_tags")
File "D:\Gdrive\website\Mezza\web00\lib\site-packages\django\template\base.py", line 1407, in add_to_builtins
builtins.append(import_library(module))
File "D:\Gdrive\website\Mezza\web00\lib\site-packages\django\template\base.py", line 1343, in import_library
(taglib_module, e))
django.template.base.InvalidTemplateLibrary: ImportError raised loading mezzanine.template.loader_tags: cannot import name 'find_template_loader'

@tienhm0202
Copy link

Add SECRET_KEY = "yj6o@&vrar6^l1u68!bxumj@xr4&5)zzk!h1qw&63^&@2d3w@#" in settings.py work for me

@novarac23
Copy link

novarac23 commented Feb 20, 2018

On an additional note, for security purposes please don't use same secret keys as the ones you posted online! :)

@m2cci-KGY
Copy link

Hi guys
I need your help to fix my problem.
first all, I don't Idea to edith the file of "settings.py" to put my SECRET_KEY.
Graphite don't run.
When I saw in my error log file I get this.

[Mon Jun 25 10:55:11.611665 2018] [:error] [pid 25414] ImproperlyConfigured: The SECRET_KEY setting must not be empty.
[Mon Jun 25 10:55:11.640350 2018] [:error] [pid 25415] mod_wsgi (pid=25415): Target WSGI script '/opt/graphite/conf/graphite.wsgi' cannot be loaded as Python module.
[Mon Jun 25 10:55:11.640462 2018] [:error] [pid 25415] mod_wsgi (pid=25415): Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
[Mon Jun 25 10:55:11.640512 2018] [:error] [pid 25415] Traceback (most recent call last):
[Mon Jun 25 10:55:11.640550 2018] [:error] [pid 25415] File "/opt/graphite/conf/graphite.wsgi", line 7, in
[Mon Jun 25 10:55:11.640681 2018] [:error] [pid 25415] application = django.core.handlers.wsgi.WSGIHandler()
[Mon Jun 25 10:55:11.640705 2018] [:error] [pid 25415] File "/usr/lib/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/core/handlers/wsgi.py", line 151, in init
[Mon Jun 25 10:55:11.640867 2018] [:error] [pid 25415] self.load_middleware()
[Mon Jun 25 10:55:11.640889 2018] [:error] [pid 25415] File "/usr/lib/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/core/handlers/base.py", line 48, in load_middleware
[Mon Jun 25 10:55:11.641065 2018] [:error] [pid 25415] if settings.MIDDLEWARE is None:
[Mon Jun 25 10:55:11.641094 2018] [:error] [pid 25415] File "/usr/lib/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/conf/init.py", line 56, in getattr
[Mon Jun 25 10:55:11.641242 2018] [:error] [pid 25415] self._setup(name)
[Mon Jun 25 10:55:11.641290 2018] [:error] [pid 25415] File "/usr/lib/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/conf/init.py", line 41, in _setup
[Mon Jun 25 10:55:11.641340 2018] [:error] [pid 25415] self._wrapped = Settings(settings_module)
[Mon Jun 25 10:55:11.641360 2018] [:error] [pid 25415] File "/usr/lib/python2.7/site-packages/Django-1.11.13-py2.7.egg/django/conf/init.py", line 129, in init

Thank you for your help

@corpsemxq
Copy link

in my case, I removed some unused import which helps me (Somehow I imported my db_route.py and there is some circle referencing in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants