Skip to main content

Expose feature flags and settings from django waffle and django constance in an endpoint.

Project description

Abstract

This project provides an API that expose settings and feature flags for the frontend.

It uses django-drf to create an endpoint to expose flags and settings configured in django-waffle and django-constance

Usage

Requirements Python (3.10–3.12; Django 6.x requires Python 3.12+) Django (4.2, 5.2 LTS, 6.0) Django REST Framework (3.15+)

Installation

Install using pip:

pip install django-frontend-settings

Add ‘frontend-settings’ to your INSTALLED_APPS setting.

INSTALLED_APPS = [
    ...
    'frontend_settings',
]

Expose the view in your urls:

from django.urls import path
from frontend_settings.views import settings as frontend_settings_view

path("frontend-settings/", frontend_settings_view, name="frontend-settings"),

Then your flags from waffle and setting from constance should be returned on a get in this route:

$ curl 'http://localhost:8000/frontend-settings/'
{"data":{"flags":{"MY_FEATURE_FLAG":true},"settings":{}}}

In that case I had FRONTEND_MY_FEATURE_FLAG flag in waffle. The default prefix for flags is FRONTEND_, if you like to change it you can do by changing the following config on settings.py:

FRONTEND_SETTINGS = {
    "WAFFLE_FLAG_PREFIX": "FRONTEND_", # Prefix used to filter out the flag that should be exposed in the endpoint
    "CONSTANCE_KEY_PREFIX": "FRONTEND_", # Prefix used to filter out the settings in constance
}

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_frontend_settings-2.2.0.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file django_frontend_settings-2.2.0.tar.gz.

File metadata

File hashes

Hashes for django_frontend_settings-2.2.0.tar.gz
Algorithm Hash digest
SHA256 c92bb1bb47eabe66b85548f900cd8cf192b0da536cc43ec196fb89854589c57c
MD5 14c90ce95707c09fef949cc3ac34871c
BLAKE2b-256 12c57dd75c89f1f8b459572f2618ecfa555c7ccdc5d1ad60bf10a39f3c8c872d

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