Correctly show enums in CharFields
All checks were successful
Tests / test (push) Successful in 24s

This commit is contained in:
Tobias Kunze 2025-03-25 18:42:14 +01:00
parent c4700932a5
commit 193b9761d0

View file

@ -85,7 +85,7 @@ def get_django_field(
max_length = field_schema.get("max_length") or 255 max_length = field_schema.get("max_length") or 255
if pattern := field_schema.get("pattern"): if pattern := field_schema.get("pattern"):
kwargs["validators"].append(RegexValidator(regex=pattern)) kwargs["validators"].append(RegexValidator(regex=pattern))
if field_schema.get("items") and (choices := field_schema["items"].get("enum")): if choices := field_schema.get("enum"):
kwargs["choices"] = ((choice, choice) for choice in choices) kwargs["choices"] = ((choice, choice) for choice in choices)
return models.CharField(max_length=max_length, **kwargs) return models.CharField(max_length=max_length, **kwargs)
elif field_type == "integer": elif field_type == "integer":