Django:上下文的某些方面在实时环境与本地环境中未正确传播



我遇到了一个奇怪的问题,在我的观点中,某些值不仅在生产环境中传递到模板。采用以下视图:

def products(request,cat_id=0):
    if cat_id:
        cat = ProductCategory.objects.filter(pk=cat_id)
        all_products = Product.objects.filter(product_category=cat_id)
        return render(request, 'drsite/products.html', {'all_products': all_products, 'product_category': cat_id})
    else:
        all_products = Product.objects.all()
    return render(request, 'drsite/products.html', {'all_products': all_products})

product_category值在实时环境中没有传递,尽管在我的本地环境中却很好。该值的目的是触发页面中元素上的活动状态,除了渲染页面上的产品。值得注意的是,产品对象是按预期的良好和呈现的。

此问题已关闭,并且似乎与目标主机上与Cloudflare相关的奇数缓存问题有关。

最新更新