macaron icon indicating copy to clipboard operation
macaron copied to clipboard

Problem in casting empty string in IntegerField

Open FrViPofm opened this issue 2 months ago • 0 comments

Hi, I got a problem in casting empty form entry with macaron.IntegerField(null=True)

I solved it by adding just a line in macaron.IntegerField.cast :

class IntegerField(FloatField):
    ...
    def cast(self, value):
        if value == None: return None
        # added FrViPofm, 2025-12-03
        elif value == "" and self.null: return None
        return int(value)

Thanks for this nice little tool that i'm using a lot

FrViPofm avatar Dec 03 '25 21:12 FrViPofm