簡體   English   中英

Django:上下文的某些方面在實時環境和本地環境中無法正確傳遞

[英]Django: Certain aspects of context not passing properly in live environment vs. local

我遇到一個奇怪的問題,即從我的觀點來看,上下文中的某些值僅在生產環境中不傳遞給模板。 采取以下觀點:

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值在實時環境中沒有傳遞,盡管在我的本地環境中傳遞的很好。 該值的目標是在頁面上呈現產品之外,還觸發頁面上元素的活動狀態。 值得注意的是,products對象通過了良好的渲染並達到了預期的效果。

此問題已關閉,似乎與目標主機上與CloudFlare相關的奇數緩存問題有關。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM