[Answer]-DJANGO: Variables passed to templates by context manager not reflecting admin changes

1👍

Move the definition of those variables into their own method or directly into passProList. Currently, they are being evaluated at the time the python file is compiled. You need them to be evaluated when they are accessed in the templates.

def get_pro_lists(pk):
    general = General.objects.get(pk=pk)
    product_list = Product.objects.all()
    shop_list = general.shop_set.all()
    return product_list, shop_list


def passProList(request):
    product_list, shop_list = get_pro_lists(1)
    return {
        'product_list': product_list,
        'shop_list': shop_list,
    }

Leave a comment