Skip to content

Commit 5266aea

Browse files
author
Droan Rishi
committed
Django-1.10 update. Field.get_prep_lookup has been removed so we don't block on live=False lookups anymore
1 parent 0dde551 commit 5266aea

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
universal = 1
33

44
[flake8]
5-
max-line-length = 119
5+
max-line-length = 135

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run_tests(self):
7070

7171
setup(
7272
name='django-livefield',
73-
version='2.6.0',
73+
version='2.7.0',
7474
description='Convenient soft-deletion support for Django models',
7575
long_description=(
7676
open('README.rst').read() + '\n\n' +

src/livefield/fields.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import django
12
from django.db import models
23

34

@@ -36,6 +37,19 @@ def get_prep_lookup(self, lookup_type, value):
3637
return super(LiveField, self).get_prep_lookup(lookup_type, value)
3738

3839

40+
class LiveFieldExact(models.lookups.Exact):
41+
def get_db_prep_lookup(self, value, connection):
42+
if not value:
43+
msg = u"LiveField doesn't support filters or excludes with a livefield=False. Try using livefield=None."
44+
raise TypeError(msg) # pylint: disable=no-member
45+
return super(LiveFieldExact, self).get_db_prep_lookup(value, connection) # pylint: disable=too-many-function-args
46+
47+
48+
# Only do this for Django >= 1.10
49+
if django.get_version().startswith("1.1"):
50+
LiveField.register_lookup(LiveFieldExact)
51+
52+
3953
try:
4054
from south.modelsinspector import add_introspection_rules
4155
add_introspection_rules([], ['^livefield.LiveField'])

0 commit comments

Comments
 (0)