2 from core.models import Controller, ControllerImages, Image
3 from collections import defaultdict
5 controller_images = ControllerImages.objects.filter(image=image)
6 existing_controllers = [cs.controller for cs in controller_images]
8 all_controllers = Controller.objects.all()
9 for controller in all_controllers:
10 if controller not in existing_controllers:
11 sd = ControllerImages(image=image, controller=controller)