0

I'm having a strange issue where certain values in a context from my views are not passing to the template in a production environment only. Take the following view:

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})

The product_category value is not passing in a live environment, although is passing just fine in my local environment. The goal of that value is to trigger an active state on an element in the page in addition to rendering the products on the page. Worth noting is the products object is passing fine and rendering as expected.

  • Your view code is fine, can we see the template? – Jessie Mar 13 '17 at 18:51
  • Thank you - the issue has resolved itself and I'm not sure why/how. I suspect there was a caching issue resulting from CloudFlare (which I was unaware of until recently). Thank you for your help. – GeranTabee Mar 17 '17 at 16:32

1 Answers1

0

This issue is closed, and seems to have been related to an odd caching issue related to CloudFlare on the destination host.