| 1391 | return value |
| 1392 | |
| 1393 | def prepare_query_value(self, op, value): |
| 1394 | if value is None: |
| 1395 | return None |
| 1396 | |
| 1397 | # XXX ValidationError raised outside of the "validate" method. |
| 1398 | if isinstance(value, Document): |
| 1399 | if value.pk is None: |
| 1400 | self.error( |
| 1401 | "You can only reference documents once they have" |
| 1402 | " been saved to the database" |
| 1403 | ) |
| 1404 | value_dict = {"_id": value.pk} |
| 1405 | for field in self.fields: |
| 1406 | value_dict.update({field: value[field]}) |
| 1407 | |
| 1408 | return value_dict |
| 1409 | |
| 1410 | raise NotImplementedError |
| 1411 | |
| 1412 | def validate(self, value): |
| 1413 | if not isinstance(value, self.document_type): |