Skip to content

Commit

Permalink
Merge pull request #56 from Certn/django3
Browse files Browse the repository at this point in the history
Django 3.x compatibility
  • Loading branch information
Robert MacCloy authored Oct 15, 2020
2 parents 0fb9c0f + 674d38c commit a385030
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ matrix:
env: DJANGO_VERSION_CEILING=2.3 DJANGO_DB_ENGINE=postgres DJANGO_DB_NAME=testdb DJANGO_DB_USER=postgres
- python: 3.6
env: DJANGO_VERSION_CEILING=2.3 DJANGO_DB_ENGINE=mysql DJANGO_DB_NAME=testdb DJANGO_DB_USER=travis
- python: 3.6
env: DJANGO_VERSION_CEILING=3.1 DJANGO_DB_ENGINE=postgres DJANGO_DB_NAME=testdb DJANGO_DB_USER=postgres
- python: 3.6
env: DJANGO_VERSION_CEILING=3.1 DJANGO_DB_ENGINE=mysql DJANGO_DB_NAME=testdb DJANGO_DB_USER=travis
- python: 3.7
env: DJANGO_VERSION_CEILING=1.12 DJANGO_DB_ENGINE=sqlite
- python: 3.7
Expand All @@ -82,6 +86,19 @@ matrix:
env: DJANGO_VERSION_CEILING=2.3 DJANGO_DB_ENGINE=postgres DJANGO_DB_NAME=testdb DJANGO_DB_USER=postgres
- python: 3.7
env: DJANGO_VERSION_CEILING=2.3 DJANGO_DB_ENGINE=mysql DJANGO_DB_NAME=testdb DJANGO_DB_USER=travis
- python: 3.7
env: DJANGO_VERSION_CEILING=3.1 DJANGO_DB_ENGINE=postgres DJANGO_DB_NAME=testdb DJANGO_DB_USER=postgres
- python: 3.7
env: DJANGO_VERSION_CEILING=3.1 DJANGO_DB_ENGINE=mysql DJANGO_DB_NAME=testdb DJANGO_DB_USER=travis
- python: 3.8
env: DJANGO_VERSION_CEILING=2.3 DJANGO_DB_ENGINE=postgres DJANGO_DB_NAME=testdb DJANGO_DB_USER=postgres
- python: 3.8
env: DJANGO_VERSION_CEILING=2.3 DJANGO_DB_ENGINE=mysql DJANGO_DB_NAME=testdb DJANGO_DB_USER=travis
- python: 3.8
env: DJANGO_VERSION_CEILING=3.1 DJANGO_DB_ENGINE=postgres DJANGO_DB_NAME=testdb DJANGO_DB_USER=postgres
- python: 3.8
env: DJANGO_VERSION_CEILING=3.1 DJANGO_DB_ENGINE=mysql DJANGO_DB_NAME=testdb DJANGO_DB_USER=travis

install:
- pip install "Django<$DJANGO_VERSION_CEILING" mysqlclient psycopg2
- "pip install flake8 pylint pytest pytest-django"
Expand Down
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Contributors
| `John Lynn <http://github.com/jlynn>`_
| `Dylan Verheul <http://github.com/dyve>`_
| `Grant McConnaughey <http://github.com/grantmcconnaughey>`_
| `Luke Burden <http://github.com/lukeburden>`_
| `James Addison <http://github.com/jaddison>`_
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

3.3.0
--------------------
- Django 3.x support
- switch to BooleanField as base (Django 4.x deprecation)

3.2.1
--------------------
- Fix rST formatting in this file to pass PyPI rendering check
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


install_requires = (
'Django>=1.11,<2.3',
'Django>=1.11,<4',
)


Expand Down Expand Up @@ -67,7 +67,7 @@ def run_tests(self):

setup(
name='django-livefield',
version='3.2.1',
version='3.3.0',
description='Convenient soft-deletion support for Django models',
long_description=(
open('README.rst').read() + '\n\n' +
Expand All @@ -79,6 +79,8 @@ def run_tests(self):
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Framework :: Django :: 3.0',
'Framework :: Django :: 3.1',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
Expand Down
9 changes: 7 additions & 2 deletions src/livefield/fields.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import django
from django.db import models

if django.VERSION < (2, 1):
BooleanField = models.NullBooleanField
else:
BooleanField = models.BooleanField

class LiveField(models.NullBooleanField):

class LiveField(BooleanField):
"""Support uniqueness constraints and soft-deletion.
Similar to a BooleanField, but stores False as NULL. This lets us use
Expand All @@ -14,7 +19,7 @@ class LiveField(models.NullBooleanField):
description = u'Soft-deletion status'

def __init__(self, *args, **kwargs):
super(LiveField, self).__init__(default=True, null=True)
super(LiveField, self).__init__(default=True, null=True, blank=True)

def get_prep_value(self, value):
# Convert in-Python value to value we'll store in DB
Expand Down

0 comments on commit a385030

Please sign in to comment.