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 33from django .conf import settings
44
55class ReplicaRouter :
6- read_replicas = settings .READ_DATABASE_URLS
6+ read_replicas = list ( settings .DATABASES . keys ())
77
88 def db_for_read (self , model , ** hints ):
99 return random .choice (self .read_replicas )
Original file line number Diff line number Diff line change 113113
114114DATABASES = {"default" : dj_database_url .parse (DATABASE_URL ), }
115115
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 ("," )
117117
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 )
120120
121- # DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter", ]
121+ DATABASE_ROUTERS = ["sensorsafrica.router.ReplicaRouter" , ]
122122
123123# Password validation
124124# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
You can’t perform that action at this time.
0 commit comments