Autogenerate secret key

This commit is contained in:
Tomasz 2021-01-28 20:48:04 +01:00
parent 220ecbf243
commit bc8ad0dee2
4 changed files with 3 additions and 14 deletions

View file

@ -1 +0,0 @@
SECRET_KEY = VULCANWEBKEY

View file

@ -25,12 +25,7 @@ And in frontend:
```shell
npm install
```
## 2. Create .env and make migrations
In the .env file put the code:
```shell
SECRET_KEY = VULCANWEBKEY
```
After saving the files, we migrate with these commands:
## 2. Make migrations
```shell
python manage.py makemigrations
python manage.py migrate

View file

@ -1,6 +1,5 @@
beautifulsoup4==4.9.3
bs4==0.0.1
Django==3.1.3
python-dotenv==0.15.0
requests==2.24.0
cryptography==3.2.1

View file

@ -12,7 +12,7 @@ https://docs.djangoproject.com/en/3.1/ref/settings/
from pathlib import Path
import os
import dotenv
from cryptography.fernet import Fernet
ROOT_PATH = os.path.dirname(__file__)
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -22,11 +22,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
dotenv_file = os.path.join(BASE_DIR, ".env")
if os.path.isfile(dotenv_file):
dotenv.load_dotenv(dotenv_file)
SECRET_KEY = os.environ['SECRET_KEY'] # Instead of your actual secret key
SECRET_KEY = Fernet.generate_key().decode('utf-8')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True