1060 | | if field.is_relation: |
1061 | | # QuerySets implement is_compatible_query_object_type() to |
1062 | | # determine compatibility with the given field. |
1063 | | if hasattr(value, 'is_compatible_query_object_type'): |
1064 | | if not value.is_compatible_query_object_type(opts, field): |
1065 | | raise ValueError( |
1066 | | 'Cannot use QuerySet for "%s": Use a QuerySet for "%s".' % |
1067 | | (value.model._meta.model_name, opts.object_name) |
1068 | | ) |
1069 | | elif hasattr(value, '_meta'): |
1070 | | self.check_query_object_type(value, opts, field) |
1071 | | elif hasattr(value, '__iter__'): |
1072 | | for v in value: |
1073 | | self.check_query_object_type(v, opts, field) |
| 1060 | # QuerySets implement is_compatible_query_object_type() to |
| 1061 | # determine compatibility with the given field. |
| 1062 | if hasattr(value, 'is_compatible_query_object_type'): |
| 1063 | if not value.is_compatible_query_object_type(opts, field): |
| 1064 | raise ValueError( |
| 1065 | 'Cannot use QuerySet for "%s": Use a QuerySet for "%s".' % |
| 1066 | (value.model._meta.model_name, opts.object_name) |
| 1067 | ) |
| 1068 | elif hasattr(value, '_meta'): |
| 1069 | self.check_query_object_type(value, opts, field) |
| 1070 | elif hasattr(value, '__iter__'): |
| 1071 | for v in value: |
| 1072 | self.check_query_object_type(v, opts, field) |
1170 | | # Prevent iterator from being consumed by check_related_objects() |
1171 | | if isinstance(value, Iterator): |
1172 | | value = list(value) |
1173 | | self.check_related_objects(field, value, opts) |
| 1169 | if field.is_relation: |
| 1170 | # Prevent iterator from being consumed by check_related_objects() |
| 1171 | if isinstance(value, Iterator): |
| 1172 | value = list(value) |
| 1173 | self.check_related_objects(field, value, opts) |