Skip to content

Commit

Permalink
Merge pull request #4 from rvianello/rvianello/update-to-django-2.0
Browse files Browse the repository at this point in the history
update to django 2.0
  • Loading branch information
rvianello committed Aug 16, 2018
2 parents 7bd2f40 + 8e6f435 commit d687dfb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ install:
# create and activate the build/test environment
- conda create -q -n tenv python=$TRAVIS_PYTHON_VERSION
- source activate tenv
- conda install -q django=1.11 psycopg2
- conda install -q django psycopg2
- conda install -q -c rdkit rdkit rdkit-postgresql
- python setup.py develop

Expand Down
24 changes: 15 additions & 9 deletions django_rdkit/models/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals

from django import VERSION as DJANGO_VERSION
from django.utils import six
from django.utils.translation import ugettext_lazy as _
from django.db.models import Lookup, Transform
Expand All @@ -12,7 +13,6 @@

__all__ = ["MolField", "RxnField", "BfpField", "SfpField",]


##########################################
# Molecule Field

Expand All @@ -25,10 +25,13 @@ def db_type(self, connection):

def get_placeholder(self, value, compiler, connection):
if hasattr(value, 'as_sql'):
# No value used for expressions, substitute in
# the column name instead.
sql, _ = compiler.compile(value)
return sql
if DJANGO_VERSION > (2,):
return '%s'
else:
# No value used for expressions, substitute in
# the column name instead.
sql, _ = compiler.compile(value)
return sql
else:
return 'mol_from_pkl(%s)'

Expand Down Expand Up @@ -124,10 +127,13 @@ def db_type(self, connection):

def get_placeholder(self, value, compiler, connection):
if hasattr(value, 'as_sql'):
# No value used for expressions, substitute in
# the column name instead.
sql, _ = compiler.compile(value)
return sql
if DJANGO_VERSION > (2,):
return '%s'
else:
# No value used for expressions, substitute in
# the column name instead.
sql, _ = compiler.compile(value)
return sql
else:
return 'bfp_from_binary_text(%s)'

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_packages(package):

setup(
name='django-rdkit',
version='0.0.6',
version='0.1.0',
description='',
packages = get_packages('django_rdkit'),
zip_safe=False,
Expand Down

0 comments on commit d687dfb

Please sign in to comment.