Skip to content

Add service URI parsing support #165

Description

@codingjoe

Code of Conduct

  • I agree to follow Django's Code of Conduct

Package Information

  • dj-database-url
  • django-service-urls

Problem

With the JazzBand sailing off into the sunset and dj-database-url being one of the most downloaded Django packages on PyPi, I'd love to make a push to add a URL settings parser to Django.

Rationale

URI-based credentials have become the norm for most datastores. From RDBs to KV stores, their CLIs usually support URIs natively. Yet Django doesn't, even though the 12-factor-fanclub and the Django community are heavily overlapping.

I believe most people don't spend a second thought before installing dj-database-url by default. However, with the JazzBand end, I think this package has earned its spot in Django's utils and future DSF support.

Scope limitation

This proposal does NOT aim to include environment parsing. The proposal is limited to parsing URIs into service setting objects. Nothing more. URI may be provided however a user chooses to. 3rd-parties may expand on the parser and use it to provide narrower integrations.

Additional Details

#8562
ticket-28236

Implementation Details

I am not saying to include the whole package, but the dictionary parser.

Especially with the email setting becoming a dictionary too. We can provide a neat experience for external services.

Something like

from django.conf.utils import parse_service_uri

DATABASE = {
    "default": parse_service_uri(os.getenv("DATABASE_URL")),
}

CACHES = {
    "default": parse_service_uri(os.getenv("REDIS_URL"), options={
        "pool_class": "redis.BlockingConnectionPool"
    }),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions