Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Converts a list to a django queryset
def list_to_queryset(model_list):
if len(model_list) > 0:
return model_list[0].__class__.objects.filter(
pk__in=[obj.pk for obj in model_list])
else:
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment