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.6, 3.7, 3.8, 3.9) Django (2.2, 3.0, 3.1, 3.2)

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 frontend_settings.views import settings as frontend_settings_view

url(r"^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": "FRONTEND_SETTINGS", # Name of 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-1.0.0.tar.gz (8.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: django_frontend_settings-1.0.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for django_frontend_settings-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a58fbda4a06b438b6598eb99947cef4b0b1436f4d9469f4d64d12ecc0f957508
MD5 f0d88b0e50d83caf6c59e3796876eba8
BLAKE2b-256 8e3305f918889d4a1f2f73e9d11a4be7423c7e5f048086349bccc6eebd487868

See more details on using hashes here.

Supported by

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