Skip to content

Commit 42603cf

Browse files
committed
fix type check
1 parent 64c9aea commit 42603cf

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

django_enum/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def to_python(self, value: Any) -> Union[Choices, Any]:
181181
return self._try_coerce(value)
182182
except ValueError as err:
183183
raise ValidationError(
184-
f"'{value}' is not a valid {self.enum.__name__}."
184+
f"'{value}' is not a valid "
185+
f"{self.enum.__name__ if self.enum else ''}."
185186
) from err
186187

187188
def validate(self, value: Any, model_instance: Model):

django_enum/tests/examples/migrations/0001_initial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by Django 3.2.14 on 2022-08-09 03:04
22

3-
from django.db import migrations, models
43
import django_enum.fields
4+
from django.db import migrations, models
55

66

77
class Migration(migrations.Migration):

0 commit comments

Comments
 (0)