I have the following query:
Child.objects.filter(
foreign_key_field__in=Parent.objects.filter(param=something))
The view dies with:
invalid literal for int() with base 10: 'value of something'
It seems to me that the foreign_key_field expects an id of some kind, and I’m giving it an actual value. Am I doing something wrong? Is this possible?
The goal is to avoid iterating over the child_set of the parent to call another query-generating method in the child, which causes a query to be generated for each and every single object returned. Instead, I want to induce the ORM to grab all the matching children in one query, and iterate over them as normally.
The question is are you doing:
or
The first version will work, the second version will give you the “invalid literal for int() with base 10” error.