Skip to content

Commit

Permalink
Add label from text
Browse files Browse the repository at this point in the history
What about changing label of pydantic model as title in drf_field? I want to change label field.
  • Loading branch information
shkangomelet authored Jul 15, 2024
1 parent 03bd861 commit 9bc0c1f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/drf_pydantic/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ def _convert_field(field: pydantic.fields.FieldInfo) -> serializers.Field:
):
drf_field_kwargs["help_text"] = field.description

# Adding label as title
if (
field.title is not pydantic_core.PydanticUndefined
and field.title is not None
):
drf_field_kwargs["label"] = field.title

# Process constraints
for item in field.metadata:
if isinstance(item, pydantic.StringConstraints):
Expand Down

0 comments on commit 9bc0c1f

Please sign in to comment.