def make_channel(app_model,search_field):
    from django.db import models
    app_label, model_name = app_model.split(".")
    model = models.get_model(app_label, model_name)

    class AjaxChannel(object):

        def get_query(self,q,request):
            """ return a query set searching for the query string q """
            kwargs = { "%s__icontains" % search_field : q }
            return model.objects.filter(**kwargs).order_by(search_field)

        def format_item(self,obj):
            """ format item for simple list of currently selected items """
            return unicode(obj)

        def format_result(self,obj):
            """ format search result for the drop down of search results. may include html """
            return unicode(obj)

        def get_objects(self,ids):
            """ get the currently selected objects """
            return model.objects.filter(pk__in=ids).order_by(search_field)

    return AjaxChannel()
Create a new Node.
dataset/ETHPy150Open caseywstark/colab/colab/apps/ajax_select/__init__.py/make_channel--crossover with--dataset/ETHPy150Open pcmanus/ccm/ccmlib/node.py/Node.__init__