Skip to content
Snippets Groups Projects
Verified Commit 21507c67 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Add base widget

parent 6e3a1dcd
No related branches found
No related tags found
No related merge requests found
from .widgets import *
from typing import Any, Dict, List, Optional
from django.conf import settings
from django.forms.widgets import TextInput
__all__ = ("CleaveWidget",)
class CleaveWidget(TextInput):
@property
def media(self) -> Dict[str, List[str]]:
js = ["dj_cleave.js"]
if settings.get("CLEAVE_JS", None):
js.append(settings.get("CLEAVE_JS"))
return {"js": js}
def __init__(self, cleave_options: Dict[str, Any], attrs: Optional[Dict[str, str]] = None):
cleaved_attrs = {} if attrs is None else attrs.copy()
cleaved_attrs.update({f"data-dj-cleavejs-{name}": value for name, value in cleave_options.items()})
super().__init__(cleaved_attrs)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment