@csrf_exempt
def user_system_quicksearch_ajax(request):
    """Returns systems sort table"""
    search = request.POST['quicksearch']
    filters = [
        Q(**{"%s__icontains" % t: search})
        for t in models.UnmanagedSystem.search_fields
    ]

    systems = models.UnmanagedSystem.objects.filter(
        reduce(operator.or_, filters)
    )

    # For some reason systems are referencing server model classes that do not
    # exist. I have no idea how this happened but it did. If accessing the
    # server model causes and error set the server_model to None so we don't
    # get an exception later during page loads.
    # TOOD: Clean up defunt server model references
    for s in systems:
        try:
            s.server_model
        except:
            s.server_model = None

    return render_to_response(
        'user_systems/quicksearch.html',
        {'systems': systems, 'BUG_URL': BUG_URL},
        RequestContext(request)
    )
dataset/ETHPy150Open mozilla/inventory/user_systems/views.py/user_system_quicksearch_ajax/original