diff --git a/peewee_plus.py b/peewee_plus.py index 70758a9..a2ec021 100644 --- a/peewee_plus.py +++ b/peewee_plus.py @@ -367,7 +367,11 @@ class EnumField(peewee.CharField): # pylint: disable=abstract-method def python_value(self, value: str) -> enum.Enum: try: - return self.enumeration[super().python_value(value)] + return ( + None + if value is None and self.null + else self.enumeration[super().python_value(value)] + ) except KeyError: raise peewee.IntegrityError( f"Enum {self.enumeration.__name__} has no value with name '{value}'"