Skip to content

Instantly share code, notes, and snippets.

@karolyi
Created April 12, 2018 13:10
Show Gist options
  • Save karolyi/65c518c03630a540a4ecbe30f15b0a70 to your computer and use it in GitHub Desktop.
Save karolyi/65c518c03630a540a4ecbe30f15b0a70 to your computer and use it in GitHub Desktop.
Register Length() to django queryset
from django.db.models import CharField
from django.db.models.functions import Length
CharField.register_lookup(Length, 'length')
result = MyModel.objects.filter(text__length__gt=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment