edx-django-release-util

raw JSON →
1.5.0 verified Mon Apr 27 auth: no python

A Django utility library for Open edX to manage release-specific operations, such as feature gating, version comparison, and release cookie handling. Version 1.5.0 is the latest; maintained by the Open edX community.

pip install edx-django-release-util
error ModuleNotFoundError: No module named 'edx_django_release_util'
cause Library not installed or virtual environment not activated.
fix
Run pip install edx-django-release-util in the correct environment.
error AttributeError: module 'edx_django_release_util' has no attribute 'feature_gating'
cause Importing the top-level package instead of the submodule.
fix
Use from edx_django_release_util import feature_gating instead of import edx_django_release_util.
error ValueError: Invalid version string: '1.0.0a'
cause Non-standard version format passed to version comparison functions.
fix
Ensure version strings follow strict semver (e.g., '1.0.0').
gotcha The `is_feature_enabled` function requires a properly configured release cookie middleware. Ensure `ReleaseCookieMiddleware` is added to `MIDDLEWARE` in Django settings.
fix Add 'edx_django_release_util.middleware.ReleaseCookieMiddleware' to MIDDLEWARE in settings.py.
gotcha Version comparison functions expect semantic versioning (e.g., '1.0.0'). Non-standard version strings may cause errors.
fix Always use strict semver format: MAJOR.MINOR.PATCH.
deprecated The old import path `from edx_django_release_util import ...` works for top-level submodules, but import from explicit modules (e.g., `edx_django_release_util.version`) is clearer.
fix Use explicit module imports as shown in the imports section.

Quickstart: check feature gating and compare versions.

import os
from django.http import HttpResponse
from edx_django_release_util import version, feature_gating

# Example: check if a feature is gated
feature_name = 'my_new_feature'
if feature_gating.is_feature_enabled(feature_name):
    response = HttpResponse('Feature enabled')
else:
    response = HttpResponse('Feature disabled')

# Example: compare versions
current_version = '1.0.0'
minimum_version = '1.0.1'
if version.is_release_version_gt(minimum_version, current_version):
    print('Upgrade required.')