(self, options, class_name)
Check class Meta attributes to prevent common mistakes.
Check class Meta attributes to prevent common mistakes.
Check class Meta attributes to prevent common mistakes .
def _check_types(self, options, class_name):
        """
        Check class Meta attributes to prevent common mistakes.
        """
        if options is None:
            return

        checks = {
            (bool,): ["show_header", "show_footer", "orderable"],
            (int,): ["per_page"],
            (tuple, list, set): ["fields", "sequence", "exclude", "localize", "unlocalize"],
            (tuple, list, set, dict): ["linkify"],
            str: ["template_name", "prefix", "order_by_field", "page_field", "per_page_field"],
            (dict,): ["attrs", "row_attrs", "pinned_row_attrs"],
            (tuple, list, str): ["order_by"],
            (type(models.Model),): ["model"],
        }

        for types, keys in checks.items():
            for key in keys:
                value = getattr(options, key, None)
                if value is not None and not isinstance(value, types):
                    expression = "{}.{} = {}".format(class_name, key, value.__repr__())

                    raise TypeError(
                        "{} (type {}), but type must be one of ({})".format(
                            expression, type(value).__name__, ", ".join([t.__name__ for t in types])
                        )
                    )
def _check_types ( self , options , class_name ) : if options is None : return checks = { ( bool , ) : [ "show_header" , "show_footer" , "orderable" ] , ( int , ) : [ "per_page" ] , ( tuple , list , set ) : [ "fields" , "sequence" , "exclude" , "localize" , "unlocalize" ] , ( tuple , list , set , dict ) : [ "linkify" ] , str : [ "template_name" , "prefix" , "order_by_field" , "page_field" , "per_page_field" ] , ( dict , ) : [ "attrs" , "row_attrs" , "pinned_row_attrs" ] , ( tuple , list , str ) : [ "order_by" ] , ( type ( models . Model ) , ) : [ "model" ] , } for types , keys in checks . items ( ) : for key in keys : value = getattr ( options , key , None ) if value is not None and not isinstance ( value , types ) : expression = "{}.{} = {}" . format ( class_name , key , value . __repr__ ( ) ) raise TypeError ( "{} (type {}), but type must be one of ({})" . format ( expression , type ( value ) . __name__ , ", " . join ( [ t . __name__ for t in types ] ) ) )