Skip to main content

A set of simple utilities for Django apps running on Fly.io

Project description

django-flyio

PyPI - Version PyPI - Python Version


A set of simple utilities for Django apps running on Fly.io.

Note: This package is designed to work with V2 Apps. It has not been tested with V1 Apps.

Installation

pip install django-flyio

Usage

Multi-Region Fly Postgres

  1. Set your DATABASES settings to call get_db_config from django_flyio.db.

    This function reads the PRIMARY_REGION and FLY_REGION environment variables to determine the Fly region the primary database is in and the Fly region the app is currently running in.

  2. Add django_flyio.routers.FlyDBReplicaRouter to your DATABASE_ROUTERS settings.

    This router reads whether the DATABASES setting has a replica key and, if so, routes reads to the replica database.

# settings.py
from django_flyio.db import get_db_config
from django_flyio.routers import FlyDBReplicaRouter

DATABASES = get_db_config()

DATABASE_ROUTERS = [FlyDBReplicaRouter]

Middleware

To set the Fly-Server header containing the Fly server and region that served the request, add django_flyio.middleware.FlyResponseMiddleware to your MIDDLEWARE settings.

# settings.py
MIDDLEWARE = [
    # ...
    'django_flyio.middleware.FlyResponseMiddleware',
]

License

django-flyio is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_flyio-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_flyio-0.1.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file django_flyio-0.1.0.tar.gz.

File metadata

  • Download URL: django_flyio-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.0

File hashes

Hashes for django_flyio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7d9df00e6a5af3c5245c5b5bf9651df56a727cfd570cc3de4d463abb96c3c44
MD5 8bab32e753f196aa634e5d97d88cb47d
BLAKE2b-256 dcf6a9e618171273c149df54a41029d481c81b62119ad75239adfeaebb064c55

See more details on using hashes here.

File details

Details for the file django_flyio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_flyio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.0

File hashes

Hashes for django_flyio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a35f2dd10f57704d05726fa27a1d50974a53d6696e237a620ca96123acb759c1
MD5 60d627ba60bf7883f3e91123c2c280c2
BLAKE2b-256 203bec7f5e7551eca6cde8de24317ce5c7d3833036331b0ffff6169a9e265df5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page