id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 2458 [patch] Backslashes in LIKE queries are not escaped tom@… Adrian Holovaty "Say you have a model called MyModel with a ''TextField'' called ''text'' and want to get all objects where ''text'' contains a backslash. The following query, however, doesn't return anything: {{{ models.MyModel.objects.filter(text__conatins='\\') }}} This query does: {{{ models.MyModel.objects.filter(text__conatins='\\\\') }}} Here is a patch that fixes the problem: {{{ Index: django/db/models/fields/__init__.py =================================================================== --- django/db/models/fields/__init__.py (revision 3496) +++ django/db/models/fields/__init__.py (working copy) @@ -20,7 +20,7 @@ BLANK_CHOICE_NONE = [("""", ""None"")] # prepares a value for use in a LIKE query -prep_for_like_query = lambda x: str(x).replace(""%"", ""\%"").replace(""_"", ""\_"") +prep_for_like_query = lambda x: str(x).replace(""\\"", ""\\\\"").replace(""%"", ""\%"").replace(""_"", ""\_"") # returns the