Skip to content

Commit

Permalink
Merge pull request coagulant#50 from ivelum/master
Browse files Browse the repository at this point in the history
Django 1.10 integration
  • Loading branch information
GeyseR committed Oct 10, 2016
2 parents 18709c2 + 531d44f commit 5805ecd
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
- DJANGO="Django>=1.7,<1.8" DB=sqlite
- DJANGO="Django>=1.8,<1.9" DB=sqlite
- DJANGO="Django>=1.9,<1.10" DB=sqlite
- DJANGO="Django>=1.10,<1.11" DB=sqlite
install:
- export PYTHONPATH=./django_any/:$PYTHONPATH
- pip install -U $DJANGO
Expand Down
4 changes: 2 additions & 2 deletions django_any/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def get_remote_field(field):
if django.VERSION >= (1, 9):
return field.remote_field
else:
return field.target_field
return field.rel


def get_remote_field_model(field):
if django.VERSION >= (1, 9):
return field.remote_field.model
else:
return field.target_field.model
return field.rel.to
13 changes: 7 additions & 6 deletions django_any/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.core.exceptions import ValidationError
from django.core.validators import validate_ipv4_address
from django.contrib.contenttypes.models import ContentType
from django.db import models, IntegrityError
from django.db import models, IntegrityError, transaction
from django.db.models import Q
from django.db.models.fields.files import FieldFile

Expand Down Expand Up @@ -536,11 +536,12 @@ def any_model_default(model_cls, **kwargs):
attempts = 10
while True:
try:
_fill_model_fields(result, **kwargs)
result.full_clean()
result.save()
return result
except (IntegrityError, ValidationError):
with transaction.atomic():
_fill_model_fields(result, **kwargs)
result.full_clean()
result.save()
return result
except (IntegrityError, ValidationError) as ex:
attempts -= 1
if not attempts:
raise
Expand Down
8 changes: 5 additions & 3 deletions django_any/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from django.conf.urls import url
from django.contrib import admin
from django.contrib.auth.models import User
from django.test import TestCase
from django.test import TestCase, override_settings

from django_any.test import Client


def view(request):
"""
Test view that returning form
Expand Down Expand Up @@ -42,9 +44,9 @@ class TestForm(forms.Form):
url(r'^view/', view),
]

class DjangoAnyClient(TestCase):
urls = 'django_any.tests.test_client'

@override_settings(ROOT_URLCONF='django_any.tests.test_client')
class DjangoAnyClient(TestCase):
def setUp(self):
self.client = Client()

Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{27}-django1{7,8,9}
envlist = py{27}-django1{7,8,9,10}

[testenv]
setenv =
Expand All @@ -12,3 +12,4 @@ deps =
django17: Django>=1.7,<1.8
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11

0 comments on commit 5805ecd

Please sign in to comment.