Make never_cache_patterns() compatible with newer versions of Django.
Review Request #9416 — Created Dec. 2, 2017 and submitted
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 likepatterns()
, 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.
- Change Summary:
-
- Fixed a blank line.
- Fixed unused variables.
- Added the rest of a missing test that didn't make it through
git add
.
- Commit:
-
fc66bc3826692f824b672507c8a653c0ccc6c26678af7937e74f8a2cad139034dbf659a4b6f94303
- Diff:
-
Revision 2 (+125 -9)