bookomate
bookomate copied to clipboard
Secret Key not found error while migration
Describe the bug
I like to contribute to this repo,so i clone it and successfully installed all the package mentioned in the requirment.txt but when i try to migrate the table using python manage.py migrate
i am getting this secret key not found error.I have generated a new secret key from here and pasted in .env file (and yes i have renamed the file).Also i am little bit confused on how to get the database url in .env file should i have to install postgres seperately or there is any other way (some tutorial or resource link will be helpful)
To Reproduce
python manage.py migrate
Expected behavior
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/django/core/management/__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__
self._setup(name)
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/mirsahib/Desktop/bookomate/bookomate/settings/base.py", line 24, in <module>
SECRET_KEY = config('SECRET_KEY')
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/decouple.py", line 199, in __call__
return self.config(*args, **kwargs)
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/decouple.py", line 83, in __call__
return self.get(*args, **kwargs)
File "/home/mirsahib/Desktop/bookomate/env/lib/python3.8/site-packages/decouple.py", line 68, in get
raise UndefinedValueError('{} not found. Declare it as envvar or define a default value.'.format(option))
decouple.UndefinedValueError: SECRET_KEY not found. Declare it as envvar or define a default value.
Screenshots
Desktop (please complete the following information):
- OS: [e.g. Ubuntu]
- Browser [e.g. chrome]
- Version [e.g. 20.04 LTS]
Hi @mirsahib
your .env file has to be something like this:
DEBUG=True
SECRET_KEY='PUT-YOUR-SECRET-KEY-HERE'
DATABASE_URL='postgres://USER:PASSWORD@HOST:PORT/DB_NAME'
Before hand, you need to install postgresql in your machine and create a data base for the app with your postgres USER, PASSWORD, HOST (localhost), PORT (5432), and DB_NAME (whatever name your want for your db). But if you don't want all that, you can remove the DATABASE_URL line from .env file, then the web app will start by default a sqlite database for you.