File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change 3
3
from django .conf import settings
4
4
5
5
class ReplicaRouter :
6
- read_replicas = settings .READ_DATABASE_URLS
6
+ read_replicas = list ( settings .DATABASES . keys ())
7
7
8
8
def db_for_read (self , model , ** hints ):
9
9
return random .choice (self .read_replicas )
Original file line number Diff line number Diff line change 113
113
114
114
DATABASES = {"default" : dj_database_url .parse (DATABASE_URL ), }
115
115
116
- # READ_DATABASE_URLS = os.getenv("SENSORSAFRICA_READ_DATABASE_URLS", DATABASE_URL).split(",")
116
+ READ_DATABASE_URLS = os .getenv ("SENSORSAFRICA_READ_DATABASE_URLS" , DATABASE_URL ).split ("," )
117
117
118
- # for index, read_database_url in enumerate(READ_DATABASE_URLS,start=1):
119
- # DATABASES[f"read_replica_{index}"] = dj_database_url.parse(read_database_url)
118
+ for index , read_database_url in enumerate (READ_DATABASE_URLS ,start = 1 ):
119
+ DATABASES [f"read_replica_{ index } " ] = dj_database_url .parse (read_database_url )
120
120
121
- # DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter", ]
121
+ DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter" , ]
122
122
123
123
# Password validation
124
124
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
You can’t perform that action at this time.
0 commit comments