django - get_search_results : AssertionError Cannot reorder a query once a slice has been taken -


in django admin, set feature admin can search products category, when search "breastpad", show products have name of breastpad, if search "category:bra", products have category of bra.

now here problem, when total of products bigger "list_per_page", error:

assertionerror @ /admin/ecoommerce/product/ cannot reorder query once slice has been taken. 

for fixed error keep adding list_per_page 50 100, , 200. tried cut total products 50 using

all_products[:50] 

when list_per_page 50, still shows "cannot reorder query once slice has been taken" exception. please help.

class product_admin(admin.modeladmin):     def get_search_results(self, request, queryset, search_term):         # check if string contains word category:xxxxxxxxxxxx         if "category:" in search_term:             # remove word category:             the_searched_category = search_term[9:]              # search product_category name             the_searched_category = product_tw.objects.all().filter(name=the_searched_category).first()              if the_searched_category != none:                 all_products = product_tw.objects.all().filter(product_categories__in=[the_searched_category]).distinct()                 return all_products, true             else:                 return product_tw.objects.none(), true         else:             queryset, use_distinct = super(product_admin, self).get_search_results(request, queryset, search_term)             return queryset, use_distinct       list_per_page       = 100 

forgot say, inside admin.py


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -