Skip to content

add settings for html cutoff on related fields #4433

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

Closed
wants to merge 1 commit into from
Closed

add settings for html cutoff on related fields #4433

wants to merge 1 commit into from

Conversation

aschriner
Copy link

Description

Adds settings
HTML_SELECT_CUTOFF for html_cutoff
HTML_SELECT_CUTOFF_TEXT for html_cutoff_text
to allow global configuration

@tomchristie tomchristie added this to the 3.5.0 Release milestone Aug 23, 2016
html_cutoff = 1000
html_cutoff_text = _('More than {count} items...')
html_cutoff = int(api_settings.HTML_SELECT_CUTOFF)
html_cutoff_text = _(api_settings.HTML_SELECT_CUTOFF_TEXT)
Copy link
Member

Choose a reason for hiding this comment

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

Setting these defaults in __init__ would be better, as we're trying to avoid accessing settings until runtime.

Some subtleties around how best to do that, as we'd still want to preserve any value that has been set as a class attribute tho (eg user has a custom relational field, where they've overridden this value)

Copy link
Member

Choose a reason for hiding this comment

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

Might need to be something like:

Don't include these attribute on the class unless overridden, then in __init__, do something like...

if `html_cutoff` in kwargs:
    self.html_cutoff = kwargs.pop('html_cutoff')
elif not hasattr(self, 'html_cutoff`):
    # Use default from settings, unless already set as a class attribute.
    self.html_cutoff = int(api_settings.HTML_SELECT_CUTOFF)

@tomchristie
Copy link
Member

Think this is probably a valid enhancement, yup.

See the inline comment. The settings.md docs will also need updating.

@aschriner
Copy link
Author

@tomchristie thanks for the feedback. updated per your comments

@tomchristie
Copy link
Member

tomchristie commented Sep 13, 2016

Looks good! 👍
Will merge when we get started on 3.5.0.

@tomchristie
Copy link
Member

Now merged into 3.5.0 branch. #4525
Thanks! 😄

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

Successfully merging this pull request may close these issues.

2 participants