updated discovery code to align with django queryset guidance