Metadata-Version: 2.4
Name: toggly-django
Version: 0.4.1
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>=0.7.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.

## Initial context for remote variants

Requires **toggly 0.7.0 and toggly-django 0.3.0**.

```python
# settings.py: application-wide startup defaults, not incoming request values.
TOGGLY = {
    "APP_KEY": "your-app-key",
    "ENABLE_VARIANTS": True,
    "IDENTITY": "user-123",           # Stable variants identity.
    "VARIANT_GROUPS": ["beta"],        # Targeting membership.
    "VARIANT_CLAIMS": {"plan": "pro"}, # String rule attributes.
}
# Programmatic configure_toggly also accepts identity, variant_groups, variant_claims.
```

Startup context avoids an initial variants fetch with incomplete targeting followed by a second fetch. Use one variants client per fixed application-wide context; never change a shared server client's identity for each incoming request. These defaults do not replace request-local `EvaluationContext` for ordinary local boolean evaluation. Enabling remote variants retains the SDK's existing client-wide evaluated-flag behavior.

Groups are trimmed and sent as repeated parameters. Claims must be string-to-string mappings: empty names/values are omitted, whitespace is preserved, and the first 20 claim names in sorted order are sent. Omitted or empty collections send no targeting parameters. Caller collections are copied. Variants caches and conditional validators match the complete context; legacy unscoped variants caches require a fresh fetch. Global definition caches retain their existing behavior.
