Skip to content

Make secrets.json not being found an explicit error when DJANGOPROJECT_DATA_DIR is set #2097

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alexgmin
Copy link
Contributor

@alexgmin alexgmin commented Jun 15, 2025

While helping someone setup the website in their system, they faced an issue in which the secrets.json file wasn't found, and they had DJANGOPROJECT_DATA_DIR env var set (but the secrets.json was on a different directory).

The instructions tell you to have this on your bashrc/zshrc export DJANGOPROJECT_DATA_DIR=~/.djangoproject, and if set, expect a ~/.djangoproject/conf/secrets.json.
In fact there's a fallback for that but only in the env variable is not set, which the instructions never tell you about.

Removing the DJANGOPROJECT_DATA_DIR would require coordination with operations to make sure it doesn't break their setup, so for now I'd just make it error explicitly if the secrets.json file is not found, which is a good initial step.

I think there's a case in which this breaks an existing working local setup, which requires the following conditions:

  1. The env var DJANGOPROJECT_DATA_DIR is set to a path that doesn't contain secrets.json. Note that the website can work without DJANGOPROJECT_DATA_DIR being set at all.
  2. The local postgres is set up to use exactly the defaults set in DATABASES. Any difference will mean it will raise an error when trying to execute Django.

Copy link
Member

@adamzap adamzap left a comment

Choose a reason for hiding this comment

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

👍 Looks great!

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