diff options
author | Johannes Hoppe <info@johanneshoppe.com> | 2017-07-20 17:06:30 +0200 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-07-20 11:06:30 -0400 |
commit | c19b56f633e172b3c02094cbe12d28865ee57772 (patch) | |
tree | 698bf39231100f9a95ab87aa37b416eb7056e4e0 /docs | |
parent | f86b6f351d45c366f733c586127251c598dfd541 (diff) | |
download | django-c19b56f633e172b3c02094cbe12d28865ee57772.tar.gz |
Fixed #28377 -- Made combining form Media retain relative asset order.
Thanks Florian Apolloner, Mariusz Felisiak, and Tim Graham for reviews.
Diffstat (limited to 'docs')
-rw-r--r-- | docs/releases/2.0.txt | 5 | ||||
-rw-r--r-- | docs/topics/forms/media.txt | 36 |
2 files changed, 41 insertions, 0 deletions
diff --git a/docs/releases/2.0.txt b/docs/releases/2.0.txt index 81162e549f..d90b80124d 100644 --- a/docs/releases/2.0.txt +++ b/docs/releases/2.0.txt @@ -554,6 +554,11 @@ Miscellaneous * Renamed ``BaseExpression._output_field`` to ``output_field``. You may need to update custom expressions. +* In older versions, forms and formsets combine their ``Media`` with widget + ``Media`` by concatenating the two. The combining now tries to :ref:`preserve + the relative order of elements in each list <form-media-asset-order>`. + ``MediaOrderConflictWarning`` is issued if the order can't be preserved. + .. _deprecated-features-2.0: Features deprecated in 2.0 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:: <script type="text/javascript" src="http://static.example.com/actions.js"></script> <script type="text/javascript" src="http://static.example.com/whizbang.js"></script> +.. _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) + <script type="text/javascript" src="http://static.example.com/jQuery.js"></script> + <script type="text/javascript" src="http://static.example.com/calendar.js"></script> + <script type="text/javascript" src="http://static.example.com/time.js"></script> + <script type="text/javascript" src="http://static.example.com/noConflict.js"></script> + +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 ================== |