Skip to content

Problem in casting empty string in IntegerField #47

@FrViPofm

Description

@FrViPofm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions