1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-07-04 22:54:05 +02:00

Merge branch 'main' into django-5.2

This commit is contained in:
quark
2025-07-03 14:24:58 +02:00
37 changed files with 5741 additions and 1921 deletions

View File

@ -63,8 +63,16 @@ class ColorWidget(Widget):
def format_value(self, value):
if value is None:
value = 0xFFFFFF
return "#{:06X}".format(value)
if isinstance(value, str):
return value # Assume it's already a hex string like "#FFAA33"
try:
return "#{:06X}".format(value)
except Exception:
return "#FFFFFF"
def value_from_datadict(self, data, files, name):
val = super().value_from_datadict(data, files, name)
return int(val[1:], 16)
if val:
return int(val[1:], 16)
return None

View File

@ -0,0 +1,5 @@
<input type="text"
name="{{ widget.name }}"
value="{{ widget.value }}"
class="jscolor"
{% include "django/forms/widgets/attrs.html" %}>