value_to_python should encode lookup fields as ascii

This commit is contained in:
Wayne Witzel III
2017-03-08 12:30:30 -05:00
parent f3f2be4d01
commit 27fc64eb56
2 changed files with 15 additions and 0 deletions

View File

@@ -148,6 +148,11 @@ class FieldLookupBackend(BaseFilterBackend):
return field.to_python(value)
def value_to_python(self, model, lookup, value):
try:
lookup = lookup.encode("ascii")
except UnicodeEncodeError:
raise ValueError("%r is not an allowed field name. Must be ascii encodable." % lookup)
field, new_lookup = self.get_field_from_lookup(model, lookup)
# Type names are stored without underscores internally, but are presented and