Fix `add_media` util for Django 2.0

Neither `add_css` nor `add_js` exist in Django 2.0 because the method
for adding `Media` classes together has changed.

Ref: c19b56f633
fix_request_path_info
Charlie Denton 2017-10-29 00:44:48 +01:00
parent 60e56ed472
commit 120520e44d
No known key found for this signature in database
GPG Key ID: 5BBA1783DA191613
1 changed files with 8 additions and 2 deletions

View File

@ -1,11 +1,17 @@
"""
Internal utils
"""
import django
def add_media(dest, media):
"""
Optimized version of django.forms.Media.__add__() that doesn't create new objects.
Only required for Django < 2.0
"""
if django.VERSION >= (2, 0):
dest += media
else:
dest.add_css(media._css)
dest.add_js(media._js)