9 lines
331 B
Python
9 lines
331 B
Python
""" Utility functions related to database queries """
|
|
from django.conf import settings
|
|
|
|
|
|
def use_read_replica_if_available(queryset):
|
|
"""
|
|
If there is a database called 'read_replica', use that database for the queryset.
|
|
"""
|
|
return queryset.using("read_replica") if "read_replica" in settings.DATABASES else queryset |