From 668c5a2ededcfa9896f29f02a4896e70fa4b571c Mon Sep 17 00:00:00 2001 From: Oracle Date: Wed, 27 Aug 2025 05:32:09 +0200 Subject: [PATCH] Fixed TOMLField defaults, and bumped version + dependencies --- asyncron/fields/toml.py | 7 ++++++- asyncron/widgets.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/asyncron/fields/toml.py b/asyncron/fields/toml.py index 305901d..fd18afd 100644 --- a/asyncron/fields/toml.py +++ b/asyncron/fields/toml.py @@ -16,7 +16,7 @@ class TOMLFormField( fields.JSONField ): "invalid": "Enter a valid TOML.", } - widget = Codearea( language = "ini" ) + widget = Codearea( language = "toml" ) def to_python(self, value): if self.disabled: return value @@ -52,6 +52,11 @@ class TOMLField( models.JSONField ): empty_strings_allowed = True description = "A TOML Field" + def __init__(self, **kwargs ): + kwargs.setdefault('default', tomlkit.document) + kwargs.setdefault('blank', True) + super().__init__( **kwargs ) + def from_db_value(self, *args, **kwargs): value_as_dict = super().from_db_value(*args, **kwargs) diff --git a/asyncron/widgets.py b/asyncron/widgets.py index 1688a1a..95714d1 100644 --- a/asyncron/widgets.py +++ b/asyncron/widgets.py @@ -14,6 +14,8 @@ class Codearea( Textarea ): tab_size = 4, **kwargs ): + if language == "toml": language = "ini" + self.language = language self.spell_check = spell_check self.extra_rows = extra_rows