[Fixed]-Comparing Models in Django

1👍

modules_a = ModelA.objects.values_list('modules', flat=True).distinct()
modules_b = ModelB.objects.values_list('new_modules', flat=True).distinct()
diff = [i for i in module_b if i not in modules_a]

https://docs.djangoproject.com/en/1.9/ref/models/querysets/#values-list

Leave a comment