Skip to content

Bug: Setting HTML_SELECT_CUTOFF global setting to None raises TypeError on RelatedField. #5140

Closed
@konradperzyna

Description

@konradperzyna

Steps to reproduce

Setting 'HTML_SELECT_CUTOFF': None in global settings and accessing a resource with related fields through Browsable API.

Expected behavior

According to http://www.django-rest-framework.org/api-guide/relations/#select-field-cutoffs this should disable html_cutoff globally.

Actual behavior

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Reason

line 91 in rest_framework/relations.py: self.html_cutoff or int(api_settings.HTML_SELECT_CUTOFF)

class RelatedField(Field):
    queryset = None
    html_cutoff = None
    html_cutoff_text = None

    def __init__(self, **kwargs):
        self.queryset = kwargs.pop('queryset', self.queryset)
        self.html_cutoff = kwargs.pop(
            'html_cutoff',
            self.html_cutoff or int(api_settings.HTML_SELECT_CUTOFF)
        )
       ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions