Skip to content

Commit

Permalink
Faster lookups with set
Browse files Browse the repository at this point in the history
  • Loading branch information
walison17 committed Sep 1, 2023
1 parent e5f5b3c commit f6393be
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions import_export/widgets.py
Expand Up @@ -145,9 +145,11 @@ def before_import_row(self, row, row_number=None, **kwargs):
return super().before_import_row(row, row_number, **kwargs)
"""

TRUE_VALUES = ["1", 1, True, "true", "TRUE", "True"]
FALSE_VALUES = ["0", 0, False, "false", "FALSE", "False"]
NULL_VALUES = ["", None, "null", "NULL", "none", "NONE", "None"]
TRUE_VALUES = {"1", 1, True, "true", "TRUE", "True"}
FALSE_VALUES = {"0", 0, False, "false", "FALSE", "False"}
NULL_VALUES = {"", None, "null", "NULL", "none", "NONE", "None"}
TRUE_RENDER_VALUE = "1"
FALSE_RENDER_VALUE = "0"

def render(self, value, obj=None):
"""
Expand All @@ -158,7 +160,7 @@ def render(self, value, obj=None):
"""
if value in self.NULL_VALUES:
return ""
return self.TRUE_VALUES[0] if value else self.FALSE_VALUES[0]
return self.TRUE_RENDER_VALUE if value else self.FALSE_RENDER_VALUE

def clean(self, value, row=None, **kwargs):
if value in self.NULL_VALUES:
Expand Down

0 comments on commit f6393be

Please sign in to comment.