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: https://github.com/django/django/commit/c19b56f633e172b3c02094cbe12d28865ee57772
This commit is contained in:
Charlie Denton
2018-01-16 10:53:34 +00:00
parent 60e56ed472
commit 120520e44d
+8 -2
View File
@@ -1,11 +1,17 @@
""" """
Internal utils Internal utils
""" """
import django
def add_media(dest, media): def add_media(dest, media):
""" """
Optimized version of django.forms.Media.__add__() that doesn't create new objects. Optimized version of django.forms.Media.__add__() that doesn't create new objects.
Only required for Django < 2.0
""" """
dest.add_css(media._css) if django.VERSION >= (2, 0):
dest.add_js(media._js) dest += media
else:
dest.add_css(media._css)
dest.add_js(media._js)