From 46605eb5913779893ba621e0fb8a9d9c4b47ef21 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Tue, 21 Feb 2017 12:32:33 -0500 Subject: [PATCH] Fix an issue filtering with non ints against foreign keys I feel like this probably worked at one time but no longer does. It makes me wonder if ForeignObjectRel was meant to be the catchall but no longer is. --- awx/api/filters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/awx/api/filters.py b/awx/api/filters.py index b196a383f0..9f34723d48 100644 --- a/awx/api/filters.py +++ b/awx/api/filters.py @@ -9,7 +9,7 @@ from django.core.exceptions import FieldError, ValidationError from django.db import models from django.db.models import Q from django.db.models.fields import FieldDoesNotExist -from django.db.models.fields.related import ForeignObjectRel, ManyToManyField +from django.db.models.fields.related import ForeignObjectRel, ManyToManyField, ForeignKey from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey from django.utils.encoding import force_text @@ -130,7 +130,7 @@ class FieldLookupBackend(BaseFilterBackend): return to_python_boolean(value, allow_none=True) elif isinstance(field, models.BooleanField): return to_python_boolean(value) - elif isinstance(field, (ForeignObjectRel, ManyToManyField, GenericForeignKey)): + elif isinstance(field, (ForeignObjectRel, ManyToManyField, GenericForeignKey, ForeignKey)): return self.to_python_related(value) else: return field.to_python(value)