Skip to content

A simple way to auto discover AJAX_LOOKUP_CHANNELS in settings.py by looking in lookups.py for registered apps.

License

Notifications You must be signed in to change notification settings

peterfarrell/django-ajax-selects-autodiscover

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-ajax-selects-autodiscover

A simple way to auto discover AJAX_LOOKUP_CHANNELS in settings.py by looking in lookups.py for registered apps.

Install this app with PIP using a GIT clone since this helper is not available in PyPi:

pip install -e git+https://github.com/peterfarrell/django-ajax-selects-autodiscover.git#egg=django-ajax-selects-autodiscover --upgrade

In your settings.py file, replace your AJAX_LOOKUP_CHANNELS with:

from ajax_selects_autodiscover import AutoDiscover

AJAX_LOOKUP_CHANNELS = AutoDiscover()

The lookup.py files is now where you define all your channels. Here is an example:

from ajax_select import LookupChannel

from login.models import Application


class ApplicationLookup(LookupChannel):
    model = Application

    def get_query(self, q, request):
        return Application.objects.find_active_by_name(q)


AJAX_LOOKUP_CHANNELS = {
    'application': ('shared.lookup', 'ApplicationLookup'),
}

About

A simple way to auto discover AJAX_LOOKUP_CHANNELS in settings.py by looking in lookups.py for registered apps.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages