Last active
October 19, 2019 13:38
-
-
Save icarovirtual/817125e1f4fa4de381f106cf2361f956 to your computer and use it in GitHub Desktop.
copy_queryset_without_annotations: final investigation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copy_queryset_without_annotations(original_qs): | |
# Create a new queryset based on the same model | |
optimized_qs = original_qs.model.objects.all() | |
# Copy the filters | |
optimized_qs.query.where = original_qs.query.where | |
optimized_qs.query.where_class = original_qs.query.where_class | |
return optimized_qs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment