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

Fix missing args on SlugField.__init__ #879

Merged

Conversation

andersonsouza
Copy link
Contributor

This PR includes the args max_length, min_length, strip and empty_value on forms.SlugField.__init__'.

These args are accepted as kwargs on SlugField and passed to CharField using super().__init__(**kwargs), where they are defined.

@@ -378,6 +378,10 @@ class SlugField(CharField):
def __init__(
self,
allow_unicode: bool = ...,
max_length: Optional[Any] = ...,
Copy link
Member

Choose a reason for hiding this comment

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

Any or int?

Copy link
Contributor Author

@andersonsouza andersonsouza Mar 20, 2022

Choose a reason for hiding this comment

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

It accepts any value and tries to cast to int. So, weird things like max_length=Decimal("10.3") are acceptable.

Also, the stub for CharField defines it as Any and inherited classes should not use a more specific type.

@sobolevn
Copy link
Member

Thank you!

@sobolevn sobolevn merged commit 10e0694 into typeddjango:master Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants