Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TextField generator respect max_length #493

Merged
merged 4 commits into from
Aug 20, 2024

Conversation

SergeiJp
Copy link
Contributor

The generator for TextField doesn't respect the max_length set in the model field.
As a result, validating the model through the serializer causes a validation error.

Switch to use gen_string instead of gen_text which respect the max_length and also support MAX_LENGTH constant
if max_length is not set on the field

PR Checklist

  • Change is covered with tests
  • CHANGELOG.md is updated if needed

Copy link
Collaborator

@amureki amureki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greetings @SergeiJp

Thank you for the contribution, this is very valuable!
I left a small comment on the code; otherwise I think we can proceed with the change. 👍

model_bakery/random_gen.py Show resolved Hide resolved
@SergeiJp SergeiJp requested a review from amureki August 20, 2024 02:31
Copy link
Collaborator

@amureki amureki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you for the contribution! 🏅

@amureki amureki merged commit ef21347 into model-bakers:main Aug 20, 2024
9 checks passed
@amureki
Copy link
Collaborator

amureki commented Aug 20, 2024

Released in 1.19.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants