mirror of
https://github.com/jazzband/django-constance.git
synced 2026-05-16 11:33:13 +00:00
Try to fix #88 by being lazy a different way.
This commit is contained in:
parent
87c83d6dba
commit
48704b9aa5
3 changed files with 11 additions and 20 deletions
|
|
@ -1,12 +1,13 @@
|
|||
from .base import Config
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from django.utils.functional import LazyObject
|
||||
|
||||
__version__ = '1.0'
|
||||
|
||||
default_app_config = 'constance.apps.ConstanceConfig'
|
||||
|
||||
try:
|
||||
from django.apps import AppConfig # noqa
|
||||
except ImportError:
|
||||
config = SimpleLazyObject(Config)
|
||||
else:
|
||||
default_app_config = 'constance.apps.ConstanceConfig'
|
||||
|
||||
class LazyConfig(LazyObject):
|
||||
def _setup(self):
|
||||
from .base import Config
|
||||
self._wrapped = Config()
|
||||
|
||||
config = LazyConfig()
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ from django.shortcuts import render_to_response
|
|||
from django.template.context import RequestContext
|
||||
from django.utils import six
|
||||
from django.utils.formats import localize
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
try:
|
||||
|
|
@ -28,10 +27,9 @@ except ImportError: # Django < 1.4
|
|||
from django.conf.urls.defaults import patterns, url
|
||||
|
||||
|
||||
from . import settings
|
||||
from .base import Config as ConfigClass
|
||||
from . import LazyConfig, settings
|
||||
|
||||
config = SimpleLazyObject(ConfigClass)
|
||||
config = LazyConfig()
|
||||
|
||||
|
||||
NUMERIC_WIDGET = forms.TextInput(attrs={'size': 10})
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
from django.apps import AppConfig
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
|
||||
|
||||
from .base import Config
|
||||
|
||||
|
||||
class ConstanceConfig(AppConfig):
|
||||
name = 'constance'
|
||||
verbose_name = _('Constance')
|
||||
|
||||
def ready(self):
|
||||
super(ConstanceConfig, self).ready()
|
||||
self.module.config = SimpleLazyObject(Config)
|
||||
|
|
|
|||
Loading…
Reference in a new issue