feat(drupal): connecte la db drupal
This commit is contained in:
parent
df3cc0d153
commit
85da91ff9d
|
@ -0,0 +1,25 @@
|
||||||
|
class Drupal2SPIPRouter:
|
||||||
|
def db_for_read(self, model, **hints):
|
||||||
|
if model._meta.app_label == 'drupal':
|
||||||
|
return 'drupal'
|
||||||
|
return None
|
||||||
|
|
||||||
|
def db_for_write(self, model, **hints):
|
||||||
|
return self.db_for_read(model, **hints)
|
||||||
|
|
||||||
|
def allow_relation(self, obj1, obj2, **hints):
|
||||||
|
"""
|
||||||
|
We disallow cross db relations.
|
||||||
|
"""
|
||||||
|
app1, app2 = obj1._meta.app_label, obj2._meta.app_label
|
||||||
|
if 'drupal' in [app1, app2]:
|
||||||
|
return app1 == app2
|
||||||
|
return None
|
||||||
|
|
||||||
|
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
||||||
|
"""
|
||||||
|
We disallow migrations for those db.
|
||||||
|
"""
|
||||||
|
if db == 'drupal':
|
||||||
|
return False
|
||||||
|
return None
|
|
@ -55,9 +55,15 @@ DATABASES = {
|
||||||
'default': env.db(
|
'default': env.db(
|
||||||
'DJANGO_DATABASE_URL',
|
'DJANGO_DATABASE_URL',
|
||||||
default='sqlite:///{}'.format(base_dir('sqlite.db')),
|
default='sqlite:///{}'.format(base_dir('sqlite.db')),
|
||||||
)
|
),
|
||||||
|
'drupal': env.db_url(
|
||||||
|
'DRUPAL_DATABASE_URL',
|
||||||
|
default='sqlite:///{}'.format(base_dir('drupal.db')),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DATABASE_ROUTERS = ['drupal2spip_lal.base.routers.Drupal2SPIPRouter']
|
||||||
|
|
||||||
# URLS
|
# URLS
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# https://docs.djangoproject.com/en/stable/ref/settings/#root-urlconf
|
# https://docs.djangoproject.com/en/stable/ref/settings/#root-urlconf
|
||||||
|
|
Loading…
Reference in New Issue