DDiran
DDiran

Reputation: 573

Offline context with Wagtail Page data (Django-Compressor)

I've got Wagtail set up with Django-Compressor (COMPRESS OFFLINE = True) which all works except for one template.

This template uses the Disqus plugin which requires:

  1. An absolute page url
  2. A unique page identifier

In my template I have included the following:

{% compress js inline %}
// My JS Code
this.page.url = "{{ page.full_url }}";
this.page.identifier = {{ page.id }};
{% endcompress %

So when accessing the page I get the error You have offline compression enabled but key "ARANDOMKEYGOESHERE" is missing from offline manifest. As per the Django-Compressor docs:

If you use any variables inside the {% compress %} blocks, make sure to list all values you require in COMPRESS_OFFLINE_CONTEXT

How would I go about adding the Page instance to the context in my settings? I thought of something like (pseudo-code):

COMPRESS_OFFLINE_CONTEXT = { 'page': request.get('page') }

Upvotes: 0

Views: 253

Answers (0)

Related Questions