-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new app and models
- Loading branch information
Showing
10 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class MyAppRouter: | ||
def db_for_read(self, model, **hints): | ||
# Specify the app you want to route to the mini_data_lake database | ||
if model._meta.app_label == 'dmz_mini_dl': | ||
return 'mini_data_lake' | ||
return 'default' # All other models go to the default database | ||
|
||
def db_for_write(self, model, **hints): | ||
if model._meta.app_label == 'dmz_mini_dl': | ||
return 'mini_data_lake' | ||
return 'default' # All other models go to the default database | ||
|
||
def allow_relation(self, obj1, obj2, **hints): | ||
# Check the app labels of both objects | ||
app_label1 = obj1._meta.app_label | ||
app_label2 = obj2._meta.app_label | ||
|
||
# If both objects are from the specific app, allow the relation | ||
if app_label1 == 'dmz_mini_dl' and app_label2 == 'dmz_mini_dl': | ||
return True | ||
|
||
# If only one of them is from the specific app, disallow the relation | ||
if app_label1 == 'dmz_mini_dl' or app_label2 == 'dmz_mini_dl': | ||
return False | ||
|
||
# Allow relations between all other models | ||
return True | ||
|
||
def allow_migrate(self, db, app_label, model_name=None, **hints): | ||
if app_label == 'dmz_mini_dl': | ||
return db == 'mini_data_lake' # Migrate the specific app to the mini_data_lake database | ||
return db == 'default' # All other apps migrate to the default database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class XfdMiniDlConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'xfd_mini_dl' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. |