python - How to combine two queryset lists in django with first list after the second list -


i have below queryset in code.

new_date = date.today() - timedelta(days=7) most_viewd_list = mytable.objects.filter(show_on_website=true).order_by('-most_viewd') new_list = most_viewd_list.filter(date_created__gte=new_date) 

now, want create new list (results_list) have new_list rows @ beginning followed most_viewed_list.

i have tried options mentioned in how combine 2 or more querysets in django view?, none of them working.

i tried below option...

 itertools import chain  result_list = list(chain(new_list, most_viewd_list)) 

but option if use result_list.count(), throwing error.

and results_list = new_list | most_viewd_list option, not getting desired result.

can tell me how can create list have new_list rows followed most_viewed_list rows.

thanks

your code creating list (of type want). take length of list len: len(result_list).


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -