2015-02-23 04:29:18 +00:00
|
|
|
"""Django DDP app config."""
|
|
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
|
|
from django.apps import AppConfig
|
2015-03-16 04:03:35 +00:00
|
|
|
from django.conf import settings, ImproperlyConfigured
|
2015-02-23 04:29:18 +00:00
|
|
|
|
2015-05-06 09:40:54 +00:00
|
|
|
from dddp import autodiscover
|
2015-04-08 06:14:22 +00:00
|
|
|
|
|
|
|
|
|
2015-02-23 04:29:18 +00:00
|
|
|
class DjangoDDPConfig(AppConfig):
|
2015-03-04 07:29:07 +00:00
|
|
|
|
|
|
|
|
"""Django app config for django-ddp."""
|
|
|
|
|
|
2015-05-06 09:40:54 +00:00
|
|
|
api = None
|
2015-02-23 04:29:18 +00:00
|
|
|
name = 'dddp'
|
|
|
|
|
verbose_name = 'Django DDP'
|
2015-05-06 09:40:54 +00:00
|
|
|
_in_migration = False
|
2015-02-23 04:29:18 +00:00
|
|
|
|
|
|
|
|
def ready(self):
|
2015-04-08 06:14:22 +00:00
|
|
|
"""Initialisation for django-ddp (setup lookups and signal handlers)."""
|
2015-03-16 04:03:35 +00:00
|
|
|
if not settings.DATABASES:
|
|
|
|
|
raise ImproperlyConfigured('No databases configured.')
|
|
|
|
|
for (alias, conf) in settings.DATABASES.items():
|
|
|
|
|
if conf['ENGINE'] != 'django.db.backends.postgresql_psycopg2':
|
|
|
|
|
raise ImproperlyConfigured(
|
|
|
|
|
'%r uses %r: django-ddp only works with PostgreSQL.' % (
|
|
|
|
|
alias, conf['backend'],
|
|
|
|
|
)
|
|
|
|
|
)
|
2015-05-06 09:40:54 +00:00
|
|
|
self.api = autodiscover()
|
|
|
|
|
self.api.ready()
|