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

Support for Django 2.0 #49

Open
wants to merge 3 commits 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
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ matrix:
env: DJANGO=">=1.10,<1.11"
- python: 3.5
env: DJANGO=">=1.11,<1.12"
- python: 3.6
env: DJANGO=">=2.0,<2.1"
- python: pypy3
env: DJANGO=">=1.8,<1.9"
- python: pypy
env: DJANGO=">=1.9,<1.10"
- python: pypy3.5-5.10.1
env: DJANGO=">=2.0,<2.1"
deploy:
provider: pypi
user: ocadotechnology
Expand Down
2 changes: 2 additions & 0 deletions closuretree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ def create_closure_model(cls):
model = type('%sClosure' % cls.__name__, (models.Model,), {
'parent': models.ForeignKey(
cls.__name__,
on_delete=models.CASCADE,
related_name=cls.closure_parentref()
),
'child': models.ForeignKey(
cls.__name__,
on_delete=models.CASCADE,
related_name=cls.closure_childref()
),
'depth': models.IntegerField(),
Expand Down
16 changes: 11 additions & 5 deletions closuretree/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@
from closuretree.models import ClosureModel
import uuid

class Blah(models.Model):
"""A test model for foreign keys"""
thing = models.CharField(max_length=32)

class TC(ClosureModel):
"""A test model."""
parent2 = models.ForeignKey(
"self",
on_delete=models.CASCADE,
related_name="children",
null=True,
blank=True
)
name = models.CharField(max_length=32)
blah = models.ForeignKey("Blah", related_name="tcs", null=True, blank=True)
blah = models.ForeignKey("Blah", on_delete=models.CASCADE, related_name="tcs", null=True, blank=True)

class ClosureMeta(object):
"""Closure options."""
Expand All @@ -47,10 +52,6 @@ class ClosureMeta(object):
def __unicode__(self):
return "%s: %s" % (self.pk, self.name)

class Blah(models.Model):
"""A test model for foreign keys"""
thing = models.CharField(max_length=32)

class TCSUB(TC):
"""Testing closure subclasses."""
extrafield = models.IntegerField()
Expand Down Expand Up @@ -125,6 +126,7 @@ class UUIDTC(ClosureModel):
primary_key = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
parent2 = models.ForeignKey(
"self",
on_delete=models.CASCADE,
related_name="children",
null=True,
blank=True,
Expand Down Expand Up @@ -340,6 +342,7 @@ class SentinelModel(ClosureModel):
"""A model using a sentinel attribute."""
location = models.ForeignKey(
"IntermediateModel",
on_delete=models.CASCADE,
null=True,
blank=True
)
Expand All @@ -361,6 +364,7 @@ class IntermediateModel(models.Model):
"""
real_parent = models.ForeignKey(
'SentinelModel',
on_delete=models.CASCADE,
null=True,
blank=True,
)
Expand Down Expand Up @@ -410,6 +414,7 @@ class TCNoMeta(ClosureModel):
"""A test model without a ClosureMeta."""
parent = models.ForeignKey(
"self",
on_delete=models.CASCADE,
related_name="children",
null=True,
blank=True
Expand Down Expand Up @@ -437,6 +442,7 @@ class Meta:

parent = models.ForeignKey(
"self",
on_delete=models.CASCADE,
related_name="children",
null=True,
blank=True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
long_description=open('README.rst').read(),
url='https://github.com/ocadotechnology/django-closuretree/',
install_requires=[
'django >= 1.4, < 1.12',
'django >= 1.4, < 2.1',
'django-autoconfig',
],
tests_require=['django-setuptest >= 0.2'],
Expand Down