I have CharField with choices, blank=True, null=False
iommi Form by default renders the field as text-input, so I passed
fields__foo__choices = ...
that makes it a select
but on submit I get IntegrityError("null value in column "foo" of relation "bar_baz" violates not-null constraint")
the choices don't contain an empty choice, but I use Field__shortcuts__choice__empty_label = "Select an option" in style
I checked self.parse_empty_string_as_none in form.py Field._parse() and it is as it should be False
but then self.parsed_data = self._parse_raw_value(self.raw_data) gets called and choice_parse returns None
for now I fixed it with
@staticmethod
def extra__pre_save(form, **kwargs):
if form.instance.foo is None:
form.instance.foo = ""
I have CharField with choices,
blank=True, null=False
iommi Form by default renders the field as text-input, so I passedthat makes it a select but on submit I get
IntegrityError("null value in column "foo" of relation "bar_baz" violates not-null constraint")
the choices don't contain an empty choice, but I use
Field__shortcuts__choice__empty_label = "Select an option"
in styleI checked
self.parse_empty_string_as_none
in form.pyField._parse()
and it is as it should beFalse
but thenself.parsed_data = self._parse_raw_value(self.raw_data)
gets called andchoice_parse
returns Nonefor now I fixed it with