I'm currently learning django, and using your tutorials. I wanted to check out your code. When I try making migrations i get this error
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Hi @RishuvDutta! You can remove the settings folder from the tutorial folder and change this os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings.dev") to this os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tutorial.settings") in the wsgi.py file. It might be possible to change the settings folder archives but that works fine for running locally.
same here i am get same error @RishuvDutta @maxg203 @FelippeJC
Hi @dangerrockstar, try copying the secret key from settings.py to settings->base.py
"C:\Program Files\JetBrains\PyCharm 2017.2.5\bin\runnerw.exe" "G:\Workstation\Web Development\Working\Infyni(Django)\venv\Scripts\python.exe" "G:/Workstation/Web Development/Working/Infyni(Django)/olp-django/manage.py" runserver 127.0.0.1:1000
Traceback (most recent call last):
File "G:/Workstation/Web Development/Working/Infyni(Django)/olp-django/manage.py", line 11, in
execute_from_command_line(sys.argv)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\core\management_init_.py", line 353, in execute_from_command_line
utility.execute()
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\core\management_init_.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\core\management_init_.py", line 195, in fetch_command
klass = load_command_class(app_name, subcommand)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\core\management_init_.py", line 39, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "c:\python27\Lib\importlib_init_.py", line 37, in import_module
import(name)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\core\management\commands\runserver.py", line 16, in
from django.db.migrations.executor import MigrationExecutor
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\migrations\executor.py", line 7, in
from .loader import MigrationLoader
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\migrations\loader.py", line 10, in
from django.db.migrations.recorder import MigrationRecorder
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\migrations\recorder.py", line 12, in
class MigrationRecorder(object):
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\migrations\recorder.py", line 26, in MigrationRecorder
class Migration(models.Model):
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\migrations\recorder.py", line 27, in Migration
app = models.CharField(max_length=255)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\models\fields_init_.py", line 1072, in init
super(CharField, self).init(*args, **kwargs)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\models\fields_init_.py", line 166, in init
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\conf_init_.py", line 55, in getattr
self.setup(name)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\conf_init.py", line 43, in setup
self.wrapped = Settings(settings_module)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\conf_init.py", line 99, in init
mod = importlib.import_module(self.SETTINGS_MODULE)
File "c:\python27\Lib\importlib_init.py", line 37, in import_module
import(name)
File "G:\Workstation\Web Development\Working\Infyni(Django)\olp-django\MxOnline\settings.py", line 21, in
from apps.users.views import CustomBackend
File "G:\Workstation\Web Development\Working\Infyni(Django)\olp-django\apps\users\views.py", line 6, in
from django.contrib.auth.backends import ModelBackend
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\contrib\auth\backends.py", line 4, in
from django.contrib.auth.models import Permission
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\contrib\auth\models.py", line 4, in
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\contrib\auth\base_user.py", line 49, in
class AbstractBaseUser(models.Model):
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\contrib\auth\base_user.py", line 50, in AbstractBaseUser
password = models.CharField(_('password'), max_length=128)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\models\fields_init_.py", line 1072, in init
super(CharField, self).init(*args, **kwargs)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\db\models\fields_init_.py", line 166, in init
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\conf_init_.py", line 55, in getattr
self.setup(name)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\conf_init.py", line 43, in _setup
self.wrapped = Settings(settings_module)
File "G:\Workstation\Web Development\Working\Infyni(Django)\venv\lib\site-packages\django\conf_init.py", line 120, in init
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Process finished with exit code 1
Hi Dear!
I have faced this error when I try to run...
I hope your good reply.
Thank you!
Just run the below in the terminal:
export DJANGO_SETTINGS_MODULE=tutorial.settings.dev
export SECRET_KEY='*'
where you replace the * with the secret in the tutorial/settings.py file.
Just run the below in the terminal:
export DJANGO_SETTINGS_MODULE=tutorial.settings.dev
export SECRET_KEY='*'
where you replace the * with the secret in the tutorial/settings.py file.
very useful !!! Thanks man
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
i have this error
export SECRET_KEY=
Just run the below in the terminal:
export DJANGO_SETTINGS_MODULE=tutorial.settings.dev
export SECRET_KEY='*'
where you replace the * with the secret in the tutorial/settings.py file.
Great! It works. For those who want to use it in Windows, replace 'export' to 'set'.