Skip to content

Commit

Permalink
Merge pull request #37 from droanr/django-1.10
Browse files Browse the repository at this point in the history
Django-1.10
  • Loading branch information
hearsaydev authored Mar 24, 2017
2 parents 0dde551 + 5266aea commit 3fb3734
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
universal = 1

[flake8]
max-line-length = 119
max-line-length = 135
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def run_tests(self):

setup(
name='django-livefield',
version='2.6.0',
version='2.7.0',
description='Convenient soft-deletion support for Django models',
long_description=(
open('README.rst').read() + '\n\n' +
Expand Down
14 changes: 14 additions & 0 deletions src/livefield/fields.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import django
from django.db import models


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


class LiveFieldExact(models.lookups.Exact):
def get_db_prep_lookup(self, value, connection):
if not value:
msg = u"LiveField doesn't support filters or excludes with a livefield=False. Try using livefield=None."
raise TypeError(msg) # pylint: disable=no-member
return super(LiveFieldExact, self).get_db_prep_lookup(value, connection) # pylint: disable=too-many-function-args


# Only do this for Django >= 1.10
if django.get_version().startswith("1.1"):
LiveField.register_lookup(LiveFieldExact)


try:
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ['^livefield.LiveField'])
Expand Down

0 comments on commit 3fb3734

Please sign in to comment.