You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using large Querysets as the input to MultipleModelField, the service fails (usually to out of memory / timeouts). This occurs because the Queryset is evaluated in clean as the MultipleModelField tries to evaluate that all items in the iteration are of type app.Thing.
This breaks even if you are handling large querysets with chunking in the process method.
class DoSomethingToThings(Service):
things = MultipleModelField("app.Thing", required=True)
def process(self):
for thing in Model.objects.all().iterator(chunk_size=2000):
pass # Do something
Not sure how to handle this in MultipleModelField as iterable datatypes like list and tuples in addition to Django Querysets. Also, it has an unsaved check for model objects.
Propose a QuerysetField that accept Django Querysets of a certain type only. I will make a PR.
The text was updated successfully, but these errors were encountered:
When using large Querysets as the input to
MultipleModelField
, the service fails (usually to out of memory / timeouts). This occurs because the Queryset is evaluated inclean
as theMultipleModelField
tries to evaluate that all items in the iteration are of typeapp.Thing
.This breaks even if you are handling large querysets with chunking in the
process
method.Not sure how to handle this in MultipleModelField as iterable datatypes like list and tuples in addition to Django Querysets. Also, it has an unsaved check for model objects.
Propose a
QuerysetField
that accept Django Querysets of a certain type only. I will make a PR.The text was updated successfully, but these errors were encountered: