{"id":19854664,"url":"https://github.com/obytes/ob-dj-feature-flags","last_synced_at":"2025-10-08T04:07:34.127Z","repository":{"id":162565584,"uuid":"636200844","full_name":"obytes/ob-dj-feature-flags","owner":"obytes","description":"a Django package for managing feature flags and controlling access to Django views \u0026 API endpoints using decorators.","archived":false,"fork":false,"pushed_at":"2023-07-01T19:19:37.000Z","size":282,"stargazers_count":3,"open_issues_count":7,"forks_count":1,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-09-14T15:58:49.129Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obytes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-04T10:27:52.000Z","updated_at":"2024-01-19T10:29:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1ed5d1a-f8c3-4961-b6d9-410171a2570f","html_url":"https://github.com/obytes/ob-dj-feature-flags","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/obytes/ob-dj-feature-flags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obytes%2Fob-dj-feature-flags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obytes%2Fob-dj-feature-flags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obytes%2Fob-dj-feature-flags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obytes%2Fob-dj-feature-flags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obytes","download_url":"https://codeload.github.com/obytes/ob-dj-feature-flags/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obytes%2Fob-dj-feature-flags/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275781369,"owners_count":25527359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T14:10:04.975Z","updated_at":"2025-09-18T14:31:54.584Z","avatar_url":"https://github.com/obytes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ob-dj-feature-flags\n\nFeature flags are a powerful technique that allows you to enable/disable specific features in your application without deploying new code. This gives you the ability to control the behavior of your application dynamically and perform A/B testing, read more about feature flags [here](https://www.atlassian.com/continuous-delivery/principles/feature-flags).\n\nob-dj-feature-flags provides a simple way to create and manage feature flags within your Django admin panel. It also provides decorators for views and viewsets to easily control access based on feature flags.\n\n## Features\n\n- Create and manage feature flags within your Django admin panel.\n- Add decorators to views and viewsets to control access based on the created feature flags.\n- Caching mechanism to reduce database hits when checking feature flag statuses.\n- Feature flags endpoint to use the same feature flags in your client apps.\n- Skip feature flags during tests or in the entire project.\n\n## Setup \u0026 Installation\n\n1. Use pip to install ob-dj-feature-flags:\n\n```shell\npip install ob-dj-feature-flags\n```\n\n2. Add \"ob_dj_feature_flags\" to your `INSTALLED_APPS` setting like this:\n\n```python\n   # settings.py\n   INSTALLED_APPS = [\n        ...\n        \"ob_dj_feature_flags.core.flags\",\n   ]\n```\n\n3. If you plan to use the created feature flags in your client apps, add the feature flags endpoint to your project's urls.py:\n\n```python\n   # urls.py\n   urlpatterns = [\n        ...\n        path('ob-dj-feature-flags/', include('ob_dj_feature_flags.apis.flags.urls')),\n   ]\n```\n\n4. Run `python manage.py migrate` to create the feature flags table.\n\n## Usage\n\n### Creating Feature Flags\n\nDefine feature flags in your Django project using the provided FeatureFlag admin. Each feature flag has a unique name and an active status.\n\n### Decorating Views\n\nUse the `@action_feature_flag` decorator to control access to individual views based on feature flags. Apply the decorator to the desired view functions or class-based views. Example:\n\n```python\nfrom ob_dj_feature_flags.utils.decorators import action_feature_flag\n\n@action_feature_flag('my_feature_flag')\ndef my_view(request):\n    # Your view logic here\n    pass\n```\n\nThis will check if the 'my_feature_flag' is active before allowing access to the view. If the flag is inactive, a JSON response with an error message and status code 404 will be returned.\n\n### Decorating Viewsets\n\nUse the `@class_feature_flag` decorator to control access to viewsets based on feature flags. Apply the decorator to the viewset classes. Example:\n\n```python\nfrom ob_dj_feature_flags.utils.decorators import class_feature_flag\n\n@class_feature_flag('my_feature_flag')\nclass MyViewSet(viewsets.ModelViewSet):\n    # Your viewset logic here\n    pass\n```\n\nThis will check if the 'my_feature_flag' is active before allowing access to any actions within the viewset. If the flag is inactive, a JSON response with an error message and status code 404 will be returned.\n\n### Use in Your Client Apps\n\nIntegrating feature flags into your client apps allows you to control the behavior and enable/disable specific features dynamically. To leverage feature flags in your client app, follow these simple steps:\n\n1. Make a GET request to the feature flags endpoint of your backend API (preferably at startup) `ob-dj-feature-flags/` (check step 3 of Setup \u0026 Installation section).\n2. The endpoint will provide a JSON response containing the list of feature flags along with their statuses.\n3. Store the feature flags and their statuses somewhere in your client app.\n4. Use the feature flags to control the behavior of your client app (you can create a wrapper function or a custom hook to simplify this process).\n\n## Skipping Feature Flags During Tests\n\nTo skip feature flags during tests, you can use the `@skip_feature_flags` decorator. This decorator can be applied to test functions or test methods to bypass the feature flag checks within the tested views or viewsets.\n\nTo use the `skip_feature_flags` decorator, import it from `ob_dj_feature_flags.utils.decorators` and apply it to your test functions or methods. Here's an example:\n\n```python\nfrom ob_dj_feature_flags.utils.decorators import skip_feature_flags\nimport pytest\n\n@skip_feature_flags\ndef test_my_view():\n    # Test logic here\n    pass\n```\n\nIn this example, the `@skip_feature_flags` decorator is applied to the test function, `test_my_view`. This will skip the feature flag checks within the tested view, allowing the test to proceed without considering the feature flags.\n\n\n## Skipping Feature Flags In The project\n\nIf you want to skip feature flags in the entire app, you can add a setting to your Django project's settings module. By setting the `SKIP_FEATURE_FLAGS` setting to `True`, all feature flag checks will be skipped when running the project.\n\n## Configuration\n\nThe package provides a caching mechanism to improve performance when checking feature flag status. By default, it uses Django's caching system. You can configure the cache backend and cache timeout in your Django project settings.\n\n## Intergration with feature flag management services\n\nYou can create a webhook endpoint to receive feature flag updates from your favorite feature flag management service. The endpoint should accept POST requests with a JSON payload containing the feature flag name and active status. Example:\n\n```json\n{\n    \"name\": \"my_feature_flag\",\n    \"active\": true\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobytes%2Fob-dj-feature-flags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobytes%2Fob-dj-feature-flags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobytes%2Fob-dj-feature-flags/lists"}