Skip to content

Change startproject template to use DJ_DATABASE_URL #92

@jfmatth

Description

@jfmatth

Code of Conduct

  • I agree to follow Django's Code of Conduct

Feature Description

I'd like to see if we can change the conf/project_template/settings.py-tpl file to utilize the DJ_DATABASE_URL module.

Currently, the DATABASES= definition looks like:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

I'd like to see it changed to:

DATABASES = {
    'default': dj_database_url.config(
        default='sqlite:///' + (BASE_DIR / 'db.sqlite3').as_posix(),
        conn_max_age=600,
        conn_health_checks=True,
    )
}

This would default to SQLite3 like it does today, but if the DATABASE_URL is defined, use the DJ_DATABASE_URL module to connect to the desired database.

Problem

Reduces the complexity of different databases in different environments (dev, qa, prod)

Request or proposal

request

Additional Details

My first new-feature suggestion, happy to help where I can.

Implementation Suggestions

Not sure the process to change a startproject template, but seems pretty easy 😄

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions