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

Concise way to externalize database URL #84

Closed
jbrucker opened this issue Nov 29, 2022 · 1 comment
Closed

Concise way to externalize database URL #84

jbrucker opened this issue Nov 29, 2022 · 1 comment
Labels
enhancement New feature or request low priority When an issue is not functionally fatal

Comments

@jbrucker
Copy link

WongNung/pdtx/settings.py

Lines 122 to 131 in 0cbb30d

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": config("DATABASE_NAME", default="wongnung"),
"USER": config("DATABASE_USERNAME", default="wongnung"),
"PASSWORD": config("DATABASE_PASSWORD", default="password"),
"HOST": config("DATABASE_HOST", default="localhost"),
"PORT": config("DATABASE_PORT", default="5432"),
}
}

Looks like WongNung is the only team to externalize their database URL!
Good.

FYI, the package dj-database-url gives you a concise way of doing this, using just one variable.
The URL syntax is standard, too.

import dj_database_url as db_url

DATABASES = {
    'default': config('DATABASE_URL', cast=db_url.parse,
                       default="sqlite:///"+BASE_DIR+"db.sqlite3")
 }

and in .env or as an environment variable.

DATABASE_URL = postgres://username:password@localhost:5432/database_name

you can also omit parts (like the password) and specify them separately in settings.py, as you did.

@GToidZ GToidZ added the enhancement New feature or request label Nov 29, 2022
@GToidZ
Copy link
Contributor

GToidZ commented Nov 29, 2022

Thank you for your suggestion, though we would not work on this enhancement anytime soon during this week. Maybe after we have more free time, we'll look into this option.

@GToidZ GToidZ added the low priority When an issue is not functionally fatal label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low priority When an issue is not functionally fatal
Projects
None yet
Development

No branches or pull requests

3 participants