Change the read_preference when querying. :param read_preference: override ReplicaSetConnection-level preference.
(self, read_preference)
| 1240 | return queryset |
| 1241 | |
| 1242 | def read_preference(self, read_preference): |
| 1243 | """Change the read_preference when querying. |
| 1244 | |
| 1245 | :param read_preference: override ReplicaSetConnection-level |
| 1246 | preference. |
| 1247 | """ |
| 1248 | validate_read_preference("read_preference", read_preference) |
| 1249 | queryset = self.clone() |
| 1250 | queryset._read_preference = read_preference |
| 1251 | queryset._cursor_obj = None # we need to re-create the cursor object whenever we apply read_preference |
| 1252 | return queryset |
| 1253 | |
| 1254 | def read_concern(self, read_concern): |
| 1255 | """Change the read_concern when querying. |