-
Notifications
You must be signed in to change notification settings - Fork 121
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
added the a scripts help generate secret key #34
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
from pathlib import Path | ||
from dotenv import load_dotenv | ||
|
||
|
||
load_dotenv() | ||
|
||
# Build paths inside the project like this: BASE_DIR / 'subdir'. | ||
|
@@ -24,12 +25,12 @@ | |
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ | ||
|
||
# SECURITY WARNING: keep the secret key used in production secret! | ||
SECRET_KEY = os.getenv("SECRET_KEY") | ||
SECRET_KEY = os.getenv('SECRET_KEY') | ||
|
||
# SECURITY WARNING: don't run with debug turned on in production! | ||
DEBUG = os.getenv("DEBUG") | ||
|
||
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '').split(',') | ||
ALLOWED_HOSTS = ["*"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the motivation for moving this into here, instead of keeping it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is easy to access rather than keeping it in .env file and other will know it part of the setting as we don't push .env to GitHub @joshaber |
||
|
||
if 'CODESPACE_NAME' in os.environ: | ||
codespace_name = os.getenv("CODESPACE_NAME") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.core.management.utils import get_random_secret_key | ||
|
||
# Generate a random secret key | ||
secret_key = get_random_secret_key() | ||
print("please copy this code and replace it in your .env file secret key") | ||
print(secret_key) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about generating the secret as part of the
postCreateCommand
, so that devs don't have to manually do anything? The script is definitely an improvement, but ideally folks wouldn't have to know/care about generating the secret.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i taught of doing this but i feel incase of doing a cloud uploading must time people need to document or change their secret keys reason i added it as script @joshaber