[Fixed]-Append does not work in For Loop

1👍

The point is, very simple, your loop hasn’t been executed. You can add an output to check.

first_sale_all_menu             = []

for one_product_category in Product_Category.objects.all().filter(slug__in=('3-pack-items-c', '3-pack-items-b', '3-pack-items', '3-pack-items-d')):
    print(1)
    link_to_mamapedia_cat   = link_to_home_page + one_product_category.get_absolute_url()
    mamapedia_category_name = one_product_category.name
    if (one_product_category.image_for_top_menu != None):
        header_image = link_to_home_page + one_product_category.main_picture.url  # TODO use thumbnail
    else:
        header_image = ''

    first_sale_all_menu.append({
        'menu_children_url'         : link_to_mamapedia_cat,
        'menu_children_title'       : mamapedia_category_name,
        'menu_product_image_src'    : header_image
    })
👤Sraw

Leave a comment