Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to work with Django 2 #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions django_hstore/managers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import unicode_literals, absolute_import

import django
from django.db import models

from django_hstore.query import HStoreQuerySet
Expand Down Expand Up @@ -28,10 +29,17 @@ def hslice(self, attr, keys, **params):


if GEODJANGO_INSTALLED:
from django.contrib.gis.db import models as geo_models
if django.VERSION[0] == 1:
from django.contrib.gis.db.models import GeoManager
class HStoreGeoManagerBase(GeoManager, HStoreManager):
pass
else:
class HStoreGeoManagerBase(HStoreManager):
pass

from django_hstore.query import HStoreGeoQuerySet

class HStoreGeoManager(geo_models.GeoManager, HStoreManager):
class HStoreGeoManager(HStoreGeoManagerBase):
"""
Object manager combining Geodjango and hstore.
"""
Expand Down
5 changes: 4 additions & 1 deletion django_hstore/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ def hupdate(self, query, attr, updates):


if GEODJANGO_INSTALLED:
from django.contrib.gis.db.models.query import GeoQuerySet
if django.VERSION[0] == 1:
from django.contrib.gis.db.models.query import GeoQuerySet
else:
GeoQuerySet = QuerySet

if django.VERSION[:2] <= (1, 7):
from django.contrib.gis.db.models.sql.query import GeoQuery
Expand Down
4 changes: 3 additions & 1 deletion django_hstore/virtual.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ def contribute_to_class(self, cls, name):
# Connect myself as the descriptor for this field
setattr(cls, name, self)
# add field to class
if DJANGO_VERSION[:2] >= (1, 8):
if DJANGO_VERSION[0] >= 2:
cls._meta.add_field(self, private=True)
elif DJANGO_VERSION[:2] >= (1, 8):
# virtual=True available since django 1.8
cls._meta.add_field(self, virtual=True)
else:
Expand Down