Metadata-Version: 2.4
Name: toggly-django
Version: 0.5.0
Summary: Django integration for Toggly feature flag management
Author-email: Toggly <support@toggly.io>
Maintainer-email: Toggly <support@toggly.io>
License: MIT
Project-URL: Homepage, https://toggly.io
Project-URL: Documentation, https://docs.toggly.io/sdks/python/django
Project-URL: Repository, https://github.com/ops-ai/toggly-sdks
Keywords: feature-flags,feature-toggles,django,toggly,experimentation
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Django :: 5.1
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Framework :: Django :: 6.1
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: toggly>=1.0.0
Requires-Dist: django>=4.2
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"

# toggly-django

## Feature blocks

With `toggly-django` 0.4.0+, render enabled and disabled content using matching
`iffeature` blocks. Set `negate=True` on the disabled block:

```html
{% load toggly_tags %}
{% iffeature "new-navigation" %}
  <nav>New navigation</nav>
{% endiffeature %}
{% iffeature "new-navigation" negate=True %}
  <nav>Classic navigation</nav>
{% endiffeature %}
```

`negate` accepts Django template expressions such as `negate=show_disabled` or
`negate=options.reverse|default:False`, resolved on each render. Use the boolean
`True` rather than the nonempty string `"False"`, which is truthy. The feature key
keeps its existing literal interpretation, whether quoted or unquoted. Both
blocks evaluate the same current request context; negation applies to the result.
If no client is configured, the positive block is hidden and the negated block
renders. Only the selected block renders its children; Django autoescaping is
preserved. These presentation gates do not replace authorization.

The legacy `{% else %}` branch remains supported for compatibility. It renders
when the final result, including any negation, is false. Prefer paired blocks in
new templates. Programmatic boolean helpers and view decorators are unchanged.

## Feature variants

Requires **toggly 1.0.0+**. Feature variants are assigned locally from the
same cached definitions used for `iffeature`/`is_feature_enabled` — there is
no separate "variants mode" to enable.

```python
# settings.py
TOGGLY = {
    "APP_KEY": "your-app-key",
    "IDENTITY": "user-123",  # Default identity used when a request/user_id isn't supplied.
}
```

```python
from toggly_django.utils import get_client

client = get_client()
variant = client.get_variant("checkout-flow", user_id=str(request.user.pk))
if variant is not None and variant.enabled and variant.name == "B":
    ...
```

See the core `toggly` package README for the full `get_variant` /
`get_variant_value` API and the Microsoft.FeatureManagement-parity assignment
rules.
