Make never_cache_patterns() compatible with newer versions of Django.

Review Request #9416 — Created Dec. 2, 2017 and submitted

Christian Hammond

never_cache_patterns() is an old function of ours that applies
Django's @never_cache decorator to a list of URLs. It was built to
work like patterns(), which doesn't exist in modern versions of
Django, and assumed older URL semantics like the ability to associate
URLs with view lookup strings, which also doesn't exist anymore.

This updates the function to be more future-proof. It no longer requires
a prefix string as the first parameter, and in fact warns if a string
that is non-empty is provided, outright failing if provided on Django
1.10 or higher (which doesn't include prefix support).

Unit tests were added to test the function with and without prefix
strings, in a way that ensures things work properly on whatever version
of Django is being tested against.

Unit tests pass on Django 1.6, 1.9, 1.10, 1.11. Opting not to bother
with older versions at this stage.

  • 0
  • 0
  • 2
  • 0
  • 2
Description From Last Updated
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.


Christian Hammond
David Trowbridge
  1. Ship It!
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-1.0.x (95f9cfc)