from django.db.models.query import CollectedObjects def update_related_field(obj, value, field): """ Set `field` to `value` for all objects related to `obj`. Based on heavily off the delete object code: http://code.djangoproject.com/browser/django/trunk/django/db/models/query.py#L824 """ # Collect all related objects. related_objs = CollectedObjects() obj._collect_sub_objects(related_objs) classes = related_objs.keys() # Bulk update the objects for performance for cls in classes: items = related_objs[cls].items() pk_list = [pk for pk, instance in items] cls._default_manager.filter(id__in=pk_list).update(**{field:value})