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

Documentation mistake in "Fields With Custom Constructors" #701

Closed
bglogic opened this issue Jul 25, 2021 · 1 comment
Closed

Documentation mistake in "Fields With Custom Constructors" #701

bglogic opened this issue Jul 25, 2021 · 1 comment
Labels
documentation Related to the documentation

Comments

@bglogic
Copy link

bglogic commented Jul 25, 2021

Background

Fields With Custom Constructors indicates that an empty string should be the default value for the label parameter.

This is directed implicitly in the code sample:

class BetterTagListField(TagListField):
    def __init__(self, label='', validators=None, remove_duplicates=True, **kwargs):

and explicitly after the code sample:

When you override a Field’s constructor, to maintain consistent behavior, you should design your constructor so that:

  • You take label=’‘, validators=None as the first two positional arguments

Problem

This doesn't maintain consistent behavior. It results in no text being rendered if no label is provided instead of the default behavior of capitalizing the variable name of the field (username -> Username, first_name -> First Name, etc.).

Solution

Update the documentation to state that the constructor's label parameter should have None as its default value. This produces the expected behavior and is consistent with the Field base class.

@greyli greyli added the documentation Related to the documentation label Jul 26, 2021
@azmeuk azmeuk closed this as completed in 4337263 Sep 9, 2021
@azmeuk
Copy link
Member

azmeuk commented Sep 9, 2021

Thank you for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Related to the documentation
Development

No branches or pull requests

3 participants