(model, write=True, hints=None)
:param model: Django model being queried
    :param write: Default to True since the DB for writes can also handle reads
    :return: Django DB alias to use for query
:param model: Django model being queried
    :param write: Default to True since the DB for writes can also handle reads
    :return: Django DB alias to use for query
: param model : Django model being queried : param write : Default to True since the DB for writes can also handle reads : return : Django DB alias to use for query
def db_for_read_write(model, write=True, hints=None):
    """
    :param model: Django model being queried
    :param write: Default to True since the DB for writes can also handle reads
    :return: Django DB alias to use for query
    """
    hints = hints or {}
    app_label = model._meta.app_label

    if app_label == SYNCLOGS_APP:
        return settings.SYNCLOGS_SQL_DB_ALIAS

    if app_label in settings.CUSTOM_DB_ROUTING:
        db_alias = settings.CUSTOM_DB_ROUTING[app_label]
        if db_alias not in settings.DATABASES:
            db_alias = connection_manager.get_django_db_alias(db_alias)
        return db_alias

    if not settings.USE_PARTITIONED_DATABASE:
        return DEFAULT_DB_ALIAS

    if app_label == BLOB_DB_APP:
        if hasattr(model, 'partition_attr'):
            return get_read_write_db_for_partitioned_model(model, hints, write)
        return DEFAULT_DB_ALIAS
    if app_label in (FORM_PROCESSOR_APP, SCHEDULING_PARTITIONED_APP):
        return get_read_write_db_for_partitioned_model(model, hints, write)
    else:
        default_db = DEFAULT_DB_ALIAS
        if not write:
            return get_load_balanced_app_db(app_label, default_db)
        return default_db
def db_for_read_write ( model , write = True , hints = None ) : hints = hints or { } app_label = model . _meta . app_label if app_label == SYNCLOGS_APP : return settings . SYNCLOGS_SQL_DB_ALIAS if app_label in settings . CUSTOM_DB_ROUTING : db_alias = settings . CUSTOM_DB_ROUTING [ app_label ] if db_alias not in settings . DATABASES : db_alias = connection_manager . get_django_db_alias ( db_alias ) return db_alias if not settings . USE_PARTITIONED_DATABASE : return DEFAULT_DB_ALIAS if app_label == BLOB_DB_APP : if hasattr ( model , 'partition_attr' ) : return get_read_write_db_for_partitioned_model ( model , hints , write ) return DEFAULT_DB_ALIAS if app_label in ( FORM_PROCESSOR_APP , SCHEDULING_PARTITIONED_APP ) : return get_read_write_db_for_partitioned_model ( model , hints , write ) else : default_db = DEFAULT_DB_ALIAS if not write : return get_load_balanced_app_db ( app_label , default_db ) return default_db