Skip to content
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

Add pythonanywhere to ALLOWED_HOSTS, CSRF_TRUSTED_ORIGINS #136

Merged
merged 4 commits into from
Feb 22, 2024

Conversation

hamishwillee
Copy link
Collaborator

@hamishwillee hamishwillee commented Feb 19, 2024

As part of allow this tutorial to run on PythonAnywhere this adds it to allowed hosts.

Also, I have added support for getting environment from a .env file in root, if it exists. This is a fallback - env variable first, then env defined in .env, then defaults.

This allows it to work on my kinds of environments.

from dotenv import load_dotenv
env_path = load_dotenv(os.path.join(BASE_DIR, '.env'))
load_dotenv(env_path)

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
# SECRET_KEY = 'django-insecure-&psk#na5l=p3q8_a+-$4w1f^lt3lx1c@d*p4x$ymm_rn7pwb87'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to get this out of the locallibrary/settings.py file if we're adding dotenv support to make beginners aware that credentials should never be exposed like this even if it's for demos.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what comes in the Django skeleton application that is built when you start and the key needs to be present. In the instructions we explain you comment this. So it is useful to show what the user needs to remove/comment out in that application "by comparison".

I find this useful as a "by comparison" - here's what you had, and here's what you now have.
It also helps me when updating the docs for the new version of Django because I compare and this is a match-ish point.

So yes, but I'm still not going to do it for what I think are better reasons than removing it.

Copy link
Member

@bsmth bsmth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments, but leaving a +1, thank you!

@hamishwillee
Copy link
Collaborator Author

Thanks very much for the review @bsmth

@hamishwillee hamishwillee merged commit 2cc5818 into main Feb 22, 2024
@hamishwillee hamishwillee deleted the with_python_anywhere branch February 22, 2024 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants