首页 > 解决方案 > 我如何在其他功能中使用 get_queryset()object 'list_object'

问题描述

class AboutView(ListView):
    template_name = 'index.html'
    model = Product

    def get_queryset(self):
       
        object_list = self.model.objects.all()
        
        return object_list
    
    def get(request, self):
        new_list = object_list
        return new_list.order_to(-'price')

标签: pythondjangogenericsdjango-modelsdjango-views

解决方案


我不知道你的目的。我认为使用self.get_queryset()。更多细节:https ://www.django-rest-framework.org/api-guide/generic-views/


推荐阅读