Wiki

Clone wiki

django-selectable / Home

Changes

Added "LIMIT" and "OFFSET" capabilities to django-selectable auto-complete QuerySets.

Use by declaring "limit" and "offset" variables in a lookup class. Either or both variables can be left blank in which case they are ignored.

For example, declaring a lookup like this:

class FruitLookup(ModelLookup):
    model = Fruit
    search_field = 'name__icontains'
    limit = 5
    offset = 6

slices the QuerySet as [5:11] which, when run through the Django ORM, yields an SQL statment which ends in: "... LIMIT 5 OFFSET 6"

On the other hand this:

class FruitLookup(ModelLookup):
    model = Fruit
    search_field = 'name__icontains'
    limit = 10

will simply limit you to 10 auto-complete options, while this:

class FruitLookup(ModelLookup):
    model = Fruit
    search_field = 'name__icontains'

will behave just as normal.

Updated