diff --git a/.env.example b/.env.example index a316a01..687d9a5 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,7 @@ -SECRET_KEY=my_secret_key +SECRET_KEY= replace with your secret key DEBUG=True -# ALLOWED_HOSTS=yourdomain.com,anotherdomain.com (Each host is separated by a comma) -ALLOWED_HOSTS=* +# Database DB_HOST=127.0.0.1 DB_PORT=3306 diff --git a/README.md b/README.md index 2d3d97e..7434758 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,20 @@ Welcome to your shiny new Codespace running Django! We've got everything fired u You've got a blank canvas to work on from a git perspective as well. There's a single initial commit with the what you're seeing right now - where you go from here is up to you! Everything you do here is contained within this one codespace. There is no repository on GitHub yet. If and when you’re ready you can click "Publish Branch" and we’ll create your repository and push up your project. If you were just exploring then and have no further need for this code then you can simply delete your codespace and it's gone forever. -To collect static files: +### to generate secretkey for django project run + +```python +python secretgen.py +``` + + + +### To collect static files: ```python python manage.py collectstatic ``` -To run this application: +### To run this application: ```python python manage.py runserver diff --git a/hello_world/settings.py b/hello_world/settings.py index 0d8efd3..545d430 100644 --- a/hello_world/settings.py +++ b/hello_world/settings.py @@ -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 = ["*"] if 'CODESPACE_NAME' in os.environ: codespace_name = os.getenv("CODESPACE_NAME") diff --git a/secretgen.py b/secretgen.py new file mode 100644 index 0000000..e7c8bea --- /dev/null +++ b/secretgen.py @@ -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) +