Skip to content

Commit

Permalink
Fixes Level transform in Django 1.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandBordage committed Mar 22, 2018
1 parent 82dc0fe commit e7011ce
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tree/transforms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import django
from django.db.models import IntegerField, Transform


class Level(Transform):
lookup_name = 'level'
function = 'length'

if django.VERSION < (1, 9):
def as_sql(self, compiler, connection):
lhs, params = compiler.compile(self.lhs)
return self.template % {'function': self.function,
'expressions': lhs}, params

@property
def template(self):
return ('%%(function)s(%%(expressions)s) / %s'
Expand Down

0 comments on commit e7011ce

Please sign in to comment.