Helper method to call to_mongo with proper inputs.
(self, value, use_db_field=True, fields=None)
| 223 | return self.to_python(value) |
| 224 | |
| 225 | def _to_mongo_safe_call(self, value, use_db_field=True, fields=None): |
| 226 | """Helper method to call to_mongo with proper inputs.""" |
| 227 | f_inputs = self.to_mongo.__code__.co_varnames |
| 228 | ex_vars = {} |
| 229 | if "fields" in f_inputs: |
| 230 | ex_vars["fields"] = fields |
| 231 | |
| 232 | if "use_db_field" in f_inputs: |
| 233 | ex_vars["use_db_field"] = use_db_field |
| 234 | |
| 235 | return self.to_mongo(value, **ex_vars) |
| 236 | |
| 237 | def prepare_query_value(self, op, value): |
| 238 | """Prepare a value that is being used in a query for PyMongo.""" |