angrybeanie_wagtail/env/lib/python3.12/site-packages/wagtail/admin/widgets/slug.py

25 lines
870 B
Python
Raw Normal View History

2025-07-25 21:32:16 +10:00
from django.conf import settings
from django.forms import widgets
class SlugInput(widgets.TextInput):
"""
Associates the input field with the Stimulus w-slug (SlugController).
Slugifies content based on `WAGTAIL_ALLOW_UNICODE_SLUGS` and supports
fields syncing their value to this field (see `TitleFieldPanel`) if
also used.
"""
def __init__(self, attrs=None):
default_attrs = {
"data-controller": "w-slug",
"data-action": "blur->w-slug#slugify w-sync:check->w-slug#compare w-sync:apply->w-slug#urlify:prevent",
"data-w-slug-allow-unicode-value": getattr(
settings, "WAGTAIL_ALLOW_UNICODE_SLUGS", True
),
"data-w-slug-compare-as-param": "urlify",
}
if attrs:
default_attrs.update(attrs)
super().__init__(default_attrs)