Fix form label display
This commit is contained in:
parent
a1a150b85e
commit
c4700932a5
1 changed files with 3 additions and 1 deletions
|
@ -51,7 +51,7 @@ def deslugify(title):
|
|||
if "_" in title:
|
||||
title.replace("_", " ")
|
||||
return title.title()
|
||||
return re.sub(r"(?<!^)(?=[A-Z])", "_", title)
|
||||
return re.sub(r"(?<!^)(?=[A-Z])", " ", title).capitalize()
|
||||
|
||||
|
||||
def get_django_field(
|
||||
|
@ -85,6 +85,8 @@ def get_django_field(
|
|||
max_length = field_schema.get("max_length") or 255
|
||||
if pattern := field_schema.get("pattern"):
|
||||
kwargs["validators"].append(RegexValidator(regex=pattern))
|
||||
if field_schema.get("items") and (choices := field_schema["items"].get("enum")):
|
||||
kwargs["choices"] = ((choice, choice) for choice in choices)
|
||||
return models.CharField(max_length=max_length, **kwargs)
|
||||
elif field_type == "integer":
|
||||
return models.IntegerField(**kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue