-
Type:
Bug
-
Resolution: Works as Designed
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: django
-
None
-
🔵 Done
-
Python Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Passing a list of ObjectIds to a filter using in results in a django.core.exceptions.ValidationError:
ids = [model.id for model in Model.objects.all()] Model.objects.filter(id__in=[ids]) # Raises this error Traceback (most recent call last): File "/Users/nstapp/Github/django-mongodb-backend/tests/performance/perftest/tests.py", line 145, in runTest self.do_task() ~~~~~~~~~~~~^^ File "/Users/nstapp/Github/django-mongodb-backend/tests/performance/perftest/tests.py", line 413, in do_task list(Model.objects.filter(id__in=[ids])) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/query.py", line 1493, in filter return self._filter_or_exclude(False, args, kwargs) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/query.py", line 1511, in _filter_or_exclude clone._filter_or_exclude_inplace(negate, args, kwargs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/query.py", line 1518, in _filter_or_exclude_inplace self._query.add_q(Q(*args, **kwargs)) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1646, in add_q clause, _ = self._add_q(q_object, can_reuse) ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1678, in _add_q child_clause, needed_inner = self.build_filter( ~~~~~~~~~~~~~~~~~^ child, ^^^^^^ ...<7 lines>... update_join_types=update_join_types, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1588, in build_filter condition = self.build_lookup(lookups, col, value) File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1415, in build_lookup lookup = lookup_class(lhs, rhs) File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/lookups.py", line 38, in __init__ self.rhs = self.get_prep_lookup() ~~~~~~~~~~~~~~~~~~~~^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/lookups.py", line 536, in get_prep_lookup return super().get_prep_lookup() ~~~~~~~~~~~~~~~~~~~~~~~^^ File "/Users/nstapp/.pyenv/versions/3.13.0/lib/python3.13/site-packages/django/db/models/lookups.py", line 321, in get_prep_lookup rhs_value = self.lhs.output_field.get_prep_value(rhs_value) File "/Users/nstapp/Github/django-mongodb-backend/django_mongodb_backend/fields/auto.py", line 25, in get_prep_value return self.to_python(value) ~~~~~~~~~~~~~~^^^^^^^ File "/Users/nstapp/Github/django-mongodb-backend/django_mongodb_backend/fields/objectid.py", line 31, in to_python raise exceptions.ValidationError( ...<3 lines>... ) from None django.core.exceptions.ValidationError: ["“[ObjectId('68b202a1c132abc3c623634d'), ObjectId('68b202a1c132abc3c623634e')]” is not a valid Object Id."]