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

Fix return type of media property

parent 46000cd7
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ from dataclasses import InitVar, asdict, dataclass
from typing import Any, Dict, List, Optional, Sequence, Union
from django.conf import settings
from django.forms import Media
from django.forms.widgets import TextInput
......@@ -20,13 +21,13 @@ class CleaveWidget(TextInput):
attrs: InitVar[Optional[Dict[str, str]]] = None
@property
def media(self) -> Dict[str, List[str]]:
def media(self) -> Media:
js = []
if settings.get("CLEAVE_JS", None):
if hasattr(settings, "CLEAVE_JS"):
# Add Cleave.js to form media if requested by setting
js.append(settings.get("CLEAVE_JS"))
js.append(settings.CLEAVE_JS)
js.append("dj_cleave.js")
return {"js": js}
return Media(js=js)
def __post_init__(self, attrs: Optional[Dict[str, str]] = None):
# Allow passing own HTML attributes, like TextInput itself
......
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