avoid unnecessary query for on_delete=DO_NOTHING #299

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+2 −0
Split
@@ -173,6 +173,8 @@ def collect(self, objs, source=None, nullable=False, collect_related=True,
if related.model._meta.auto_created:
self.add_batch(related.model, field, new_objs)
else:
+ if field.rel.on_delete == DO_NOTHING:
+ continue
sub_objs = self.related_objects(related, new_objs)
if not sub_objs:
continue