From c19b56f633e172b3c02094cbe12d28865ee57772 Mon Sep 17 00:00:00 2001 From: Johannes Hoppe Date: Thu, 20 Jul 2017 17:06:30 +0200 Subject: Fixed #28377 -- Made combining form Media retain relative asset order. Thanks Florian Apolloner, Mariusz Felisiak, and Tim Graham for reviews. --- docs/topics/forms/media.txt | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'docs/topics/forms') diff --git a/docs/topics/forms/media.txt b/docs/topics/forms/media.txt index 0bdf237a21..b98cc9e740 100644 --- a/docs/topics/forms/media.txt +++ b/docs/topics/forms/media.txt @@ -305,6 +305,42 @@ specified by both:: +.. _form-media-asset-order: + +Order of assets +--------------- + +The order in which assets are inserted into the DOM if often important. For +example, you may have a script that depends on jQuery. Therefore, combining +``Media`` objects attempts to preserve the relative order in which assets are +defined in each ``Media`` class. + +For example:: + + >>> from django import forms + >>> class CalendarWidget(forms.TextInput): + ... class Media: + ... js = ('jQuery.js', 'calendar.js', 'noConflict.js') + >>> class TimeWidget(forms.TextInput): + ... class Media: + ... js = ('jQuery.js', 'time.js', 'noConflict.js') + >>> w1 = CalendarWidget() + >>> w2 = TimeWidget() + >>> print(w1.media + w2.media) + + + + + +Combining ``Media`` objects with assets in a conflicting order results in a +``MediaOrderConflictWarning``. + +.. versionchanged:: 2.0 + + In older versions, the assets of ``Media`` objects are concatenated rather + than merged in a way that tries to preserve the relative ordering of the + elements in each list. + ``Media`` on Forms ================== -- cgit v1.3