I have a QuerySet in a view similar to the one below. I would like to be able to use the same request to other views, but I do not want to copy and paste the code. It also seems that I break the stern principal.
If I want to change the request later, I will have to change it in all of my views, which is clearly not ideal. Is there a class that I have to create, or a method in my model that would allow me to call it from different angles? Does anyone have any advice on this?
tasks = Task.objects.filter(user = request.user).order_by('-created_at', 'is_complete')
user1924060
source share