Skip to content

Commit

Permalink
fixes for Django 1.10 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrDlouhy committed Mar 20, 2016
1 parent 548590e commit cad7bbb
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion leaflet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from django.contrib.staticfiles.templatetags.staticfiles import static
from django.utils.translation import ugettext_lazy as _
from django.utils import six
import django


DEFAULT_TILES = [(_('OSM'), '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
Expand Down Expand Up @@ -201,7 +202,14 @@ def _normalize_plugins_config():

PLUGINS['__is_normalized__'] = True

_normalize_plugins_config()

default_app_config = 'leaflet.apps.LeafletConfig'

if django.VERSION >= (1, 8, 0): # otherwise is called in apps.py
if django.apps.apps.ready:
_normalize_plugins_config()
else:
_normalize_plugins_config()


class JSONLazyTranslationEncoder(DjangoJSONEncoder):
Expand Down
12 changes: 12 additions & 0 deletions leaflet/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-

from django.apps import AppConfig


class LeafletConfig(AppConfig):
name = 'leaflet'
verbose_name = "Leaflet"

def ready(self):
from . import _normalize_plugins_config
_normalize_plugins_config()
3 changes: 3 additions & 0 deletions leaflet/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def test_default_widget(self):
class DummyModel(gismodels.Model):
geom = gismodels.PointField()

class Meta:
app_label = "leaflet"


class DummyAdmin(LeafletGeoAdmin):
settings_overrides = {
Expand Down
7 changes: 7 additions & 0 deletions quicktest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class QuickDjangoTest(object):
'django.contrib.sessions',
'django.contrib.admin',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
]

def __init__(self, *args, **kwargs):
self.apps = kwargs.get('apps', [])
Expand Down Expand Up @@ -58,6 +64,7 @@ def run_tests(self):
settings.configure(
DATABASES=databases,
INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
TEMPLATES = self.TEMPLATES,
STATIC_URL='/static/'
)
if django.VERSION >= (1, 7, 0):
Expand Down

0 comments on commit cad7bbb

Please sign in to comment.