mitol-django-olposthog
This is the Open Learning OlPosthog app. It provides an API to interact with Posthog in order to check feature flags.
Installation and setup
Add the OlPosthog app:
docker-compose run -u root --rm web uv add mitol-django-olposthog
Add the following to the ready() method for your App.
from mitol.olposthog.features import configure
configure()
Common Django settings
HOSTNAME- The website's hostname.
OlPosthog app settings
All settings for the mitol-django-olposthog app are prefaced with 'POSTHOG'.
POSTHOG_ENABLED-Truein order to enable Posthog feature flags in the application.Falseto disable Posthog feature flags.POSTHOG_PROJECT_API_KEY- Required if POSTHOG_ENABLED is True. Private API key to communicate with PostHog.POSTHOG_PERSONAL_API_KEY- Optional. Personal API key for local flag evaluation. When set, the PostHog SDK evaluates flags locally without making a per-request HTTP call. Recommended for production to reduce latency and cost.POSTHOG_API_HOST- Required if POSTHOG_ENABLED is True. Host URL for the PostHog API.POSTHOG_FEATURE_FLAG_REQUEST_TIMEOUT_MS- Timeout (ms) for PostHog feature flag requests. Default:3000.POSTHOG_MAX_RETRIES- Number of times requests to PostHog should be retried after failing. Default:3.POSTHOG_POLL_INTERVAL- Seconds between PostHog flag config polling. Only relevant whenPOSTHOG_PERSONAL_API_KEYis set for local evaluation. Default:300.
Circuit breaker
The circuit breaker protects your application when PostHog is slow or unreachable. If a PostHog request takes longer than the trip threshold, the circuit opens and subsequent calls return immediately from settings.FEATURES (your local fallback) until the cooldown expires.
POSTHOG_CIRCUIT_BREAKER_TRIP_THRESHOLD_SECONDS- How long a PostHog request can take before the circuit trips. Default:6.POSTHOG_CIRCUIT_BREAKER_COOLDOWN_SECONDS- How long the circuit stays open before PostHog is retried. Default:60.
The circuit breaker applies to both is_enabled() and get_all_feature_flags().
Note: The circuit breaker is most relevant when
POSTHOG_PERSONAL_API_KEYis not set (remote evaluation). With local evaluation enabled, flag checks are served from an in-process cache populated by a background polling thread, so per-request HTTP calls — and therefore circuit-breaker trips — are rare.
Cache table creation
Add the following cache defintion to your CACHES in the settings.py file of your Django application.
CACHES = {
"durable": {
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
"LOCATION": "durable_cache",
},
}
You must create the cache included in this library. This can be done by running the following command from within the Django application that this library is being added to: ./manage.py createcachetable.
Usage
Check single feature flag value
You can check the value of a feature flag on Posthog with the following code:
from mitol.olposthog.features import is_enabled
is_enabled(<FEATURE_FLAG_NAME>)
This will return a boolean value based on whether the Posthog feature flag is True or False.
Retrieve all feature flags from Posthog
You can retrieve all the feature flags from Posthog using:
from mitol.olposthog.features import get_all_feature_flags
get_all_feature_flags()
Metadata
Release files for mitol-django-olposthog 2026.10.30
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mitol_django_olposthog-2026.10.30.tar.gz | 6.3 kB | With provenance | Details for mitol_django_olposthog-2026.10.30.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mitol_django_olposthog-2026.10.30-py3-none-any.whl | Python 3 | none | any | Details for mitol_django_olposthog-2026.10.30-py3-none-any.whl |
Total release size: 15.7 kB
Release files / mitol_django_olposthog-2026.10.30.tar.gz
| Download URL | mitol_django_olposthog-2026.10.30.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73d1b76e89e79ba7eb6e59d7ee0d2b7006cb20866f76a6d5bfe0e7d3a968aa2f
|
|
BLAKE2b-256 checksum How to use checksums |
ddcc5d4f1ef72af59a189347601e0da59412657c2741cc6a6bc10b2932c87ccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logRelease files / mitol_django_olposthog-2026.10.30-py3-none-any.whl
| Download URL | mitol_django_olposthog-2026.10.30-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
de7be77e8ae318fb2c6b2a1bf4269c1973bb87739f216c58ea25af1eee3d193f
|
|
BLAKE2b-256 checksum How to use checksums |
6ff878ea521f08078a4af9be348c67043fc7137f77d7ef6cbf8ad1212561f2ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logSecurity for mitol-django-olposthog 2026.10.30
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mitol_django_olposthog-2026.10.30.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.