[PYTHON]:リストがsetに変換されたときに自動的にソートされる問題を解決する

927 ワード

    product_names = Report_Details.objects.all().values('Product__productname').order_by('Product')
    tasknames = Report_Details.objects.all().values('taskname').order_by('Product')
    products = Report_Details.objects.all().values('Product').order_by('Product')
    product_name_list = []
    taskname_list = []
    products_list = []
    for i in product_names:
        product_name_list.append(i['Product__productname'])
    product_name_list_sort = list(set(product_name_list)) #         
    product_name_list_sort.sort(key=product_name_list.index)
    for i in tasknames:
        taskname_list.append(i['taskname'])
    taskname_list_sort = list(set(taskname_list))  #         
    taskname_list_sort.sort(key=taskname_list.index)

DJANGOでは検索に必要なソートを行う.
setデリバリーはパス_hash__および_eq__結合して完成する.
このように簡単な方法で並べ替えを変更する必要がある.