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

removed all deprecation warning for Django 1.9 #68

Merged
merged 2 commits into from
Nov 30, 2015
Merged
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
6 changes: 5 additions & 1 deletion sortedm2m/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ def clean(self, value):
for key, value in iteritems(queryset.in_bulk(value))))
return [object_list[str_(pk)] for pk in value]

def _has_changed(self, initial, data):
if django.VERSION < (1, 8):
def _has_changed(self, initial, data):
return self.has_changed(initial, data)

def has_changed(self, initial, data):
if initial is None:
initial = []
if data is None:
Expand Down
2 changes: 1 addition & 1 deletion sortedm2m/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def add_sort_value_field(self, schema_editor, model):
schema_editor.add_field(model, field)

def remove_sort_value_field(self, schema_editor, model):
field = model._meta.get_field_by_name(SORT_VALUE_FIELD_NAME)[0]
field = get_field(model, SORT_VALUE_FIELD_NAME)
schema_editor.remove_field(model, field)

def make_sort_by_field(self, model):
Expand Down
8 changes: 5 additions & 3 deletions sortedm2m_tests/test_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from django.test.utils import override_settings
from django.utils import six

from sortedm2m.compat import get_field

from .models import (
Book, Shelf, DoItYourselfShelf, Store, MessyStore, SelfReference)

Expand Down Expand Up @@ -208,10 +210,10 @@ def test_custom_sort_value_field_name(self):
# make sure that standard sort field is not used
self.assertRaises(
FieldDoesNotExist,
intermediate_model._meta.get_field_by_name,
SORT_VALUE_FIELD_NAME)
get_field,
intermediate_model, SORT_VALUE_FIELD_NAME)

field = intermediate_model._meta.get_field_by_name('diy_sort_number')
field = get_field(intermediate_model, 'diy_sort_number')
self.assertTrue(field)


Expand Down
6 changes: 3 additions & 3 deletions sortedm2m_tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from django.test import TransactionTestCase
from django.utils import six

from sortedm2m.compat import get_apps_from_state
from sortedm2m.compat import get_apps_from_state, get_field
from sortedm2m_tests.migrations_tests.models import Gallery, Photo
from .compat import skipIf
from .utils import capture_stdout
Expand Down Expand Up @@ -132,7 +132,7 @@ def test_operation_m2m_to_sorted_m2m(self):
t2 = Target.objects.create(pk=2)
t3 = Target.objects.create(pk=3)

field = M2MToSortedM2M._meta.get_field_by_name('m2m')[0]
field = get_field(M2MToSortedM2M,'m2m')
through_model = field.rel.through
# No ordering is in place.
self.assertTrue(not through_model._meta.ordering)
Expand All @@ -158,7 +158,7 @@ def test_operation_m2m_to_sorted_m2m(self):
t2 = Target.objects.get(pk=2)
t3 = Target.objects.get(pk=3)

field = M2MToSortedM2M._meta.get_field_by_name('m2m')[0]
field = get_field(M2MToSortedM2M,'m2m')
through_model = field.rel.through
# Now, ordering is there.
self.assertTrue(list(through_model._meta.ordering), ['sort_value'])
Expand Down
32 changes: 27 additions & 5 deletions test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_email@domain.com'),
Expand Down Expand Up @@ -58,10 +57,6 @@

ROOT_URLCONF = 'example.urls'

TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -98,6 +93,33 @@
'test_south_support.south_support_custom_sort_field_name',
)

if django.VERSION >= (1, 8):
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(PROJECT_ROOT, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
else:
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)
TEMPLATE_DEBUG = DEBUG

try:
from local_settings import *
except ImportError:
Expand Down