<imgsrc="_images/inheritance-b1d6d9e7c478c7dc16ac802dba655251d1a9f594.png"alt="Inheritance diagram of django_select2.util"usemap="#inheritance39128e562c"class="inheritance"/>
<emclass="property">class </em><ttclass="descclassname">django_select2.util.</tt><ttclass="descname">JSVar</tt><aclass="reference internal"href="_modules/django_select2/util.html#JSVar"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.JSVar"title="Permalink to this definition">¶</a></dt>
<p>This is a simple unicode string. This class type acts as a marker that this string is a JS variable name,
so it must not be quoted by <aclass="reference internal"href="#django_select2.util.convert_py_to_js_data"title="django_select2.util.convert_py_to_js_data"><ttclass="xref py py-func docutils literal"><spanclass="pre">convert_py_to_js_data()</span></tt></a> while rendering the JS code.</p>
<emclass="property">class </em><ttclass="descclassname">django_select2.util.</tt><ttclass="descname">JSFunction</tt><aclass="reference internal"href="_modules/django_select2/util.html#JSFunction"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.JSFunction"title="Permalink to this definition">¶</a></dt>
<p>From rendering point of view, rendering this is no different from <aclass="reference internal"href="#django_select2.util.JSVar"title="django_select2.util.JSVar"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSVar</span></tt></a>. After all, a JS varible
can refer a function instance, primitive constant or any other object. They are still all varibles.</p>
<divclass="admonition tip">
<pclass="first admonition-title">Tip</p>
<pclass="last">Do use this marker for JS functions. This will make the code clearer, and the purpose more easier to
<emclass="property">class </em><ttclass="descclassname">django_select2.util.</tt><ttclass="descname">JSFunctionInContext</tt><aclass="reference internal"href="_modules/django_select2/util.html#JSFunctionInContext"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.JSFunctionInContext"title="Permalink to this definition">¶</a></dt>
<p>A JS function name to run in context of some other Html DOM element.</p>
<p>Like :py:class:JSFunction`, this too flags the string as JS function, but with a special requirement. The JS function
needs to be invoked in the context of a Html DOM, such that, <ttclass="docutils literal"><spanclass="pre">this</span></tt> inside the function refers to that DOM instead of
<pclass="last">JS functions of this type are warapped inside special another JS function –<ttclass="docutils literal"><spanclass="pre">django_select2.runInContextHelper</span></tt>.</p>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">render_js_script</tt><big>(</big><em>inner_code</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#render_js_script"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.render_js_script"title="Permalink to this definition">¶</a></dt>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">extract_some_key_val</tt><big>(</big><em>dct</em>, <em>keys</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#extract_some_key_val"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.extract_some_key_val"title="Permalink to this definition">¶</a></dt>
<dd><p>Gets a sub-set of a <aclass="reference external"href="http://docs.python.org/2.7/library/stdtypes.html#dict"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">dict</span></tt></a>.</p>
<li><strong>keys</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#list"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">list</span></tt></a> or any iterable.) – List of subset keys, which to extract from <ttclass="docutils literal"><spanclass="pre">dct</span></tt>.</li>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">convert_py_to_js_data</tt><big>(</big><em>val</em>, <em>id_</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#convert_py_to_js_data"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.convert_py_to_js_data"title="Permalink to this definition">¶</a></dt>
<dd><p>Converts Python data type to JS data type.</p>
<p>Practically what this means is, convert <ttclass="docutils literal"><spanclass="pre">False</span></tt> to <ttclass="docutils literal"><spanclass="pre">false</span></tt>, <ttclass="docutils literal"><spanclass="pre">True</span></tt> to <ttclass="docutils literal"><spanclass="pre">true</span></tt> and so on.
It also takes care of the conversion of <aclass="reference internal"href="#django_select2.util.JSVar"title="django_select2.util.JSVar"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSVar</span></tt></a>, <aclass="reference internal"href="#django_select2.util.JSFunction"title="django_select2.util.JSFunction"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunction</span></tt></a>
and <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a>. It takes care of recursively converting lists and dictionaries
<li><strong>id</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#str"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">str</span></tt></a>) – The DOM id of the element in which context <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a> functions
should run. (This is not needed if <ttclass="docutils literal"><spanclass="pre">val</span></tt> contains no <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a>)</li>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">convert_dict_to_js_map</tt><big>(</big><em>dct</em>, <em>id_</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#convert_dict_to_js_map"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.convert_dict_to_js_map"title="Permalink to this definition">¶</a></dt>
<li><strong>dct</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/stdtypes.html#dict"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">dict</span></tt></a>) – The Python dictionary to convert.</li>
<li><strong>id</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#str"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">str</span></tt></a>) – The DOM id of the element in which context <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a> functions
should run. (This is not needed if <ttclass="docutils literal"><spanclass="pre">dct</span></tt> contains no <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a>)</li>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">convert_to_js_arr</tt><big>(</big><em>lst</em>, <em>id_</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#convert_to_js_arr"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.convert_to_js_arr"title="Permalink to this definition">¶</a></dt>
<li><strong>lst</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#list"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">list</span></tt></a> or Any iterable) – The Python iterable to convert.</li>
<li><strong>id</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#str"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">str</span></tt></a>) – The DOM id of the element in which context <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a> functions
should run. (This is not needed if <ttclass="docutils literal"><spanclass="pre">lst</span></tt> contains no <aclass="reference internal"href="#django_select2.util.JSFunctionInContext"title="django_select2.util.JSFunctionInContext"><ttclass="xref py py-class docutils literal"><spanclass="pre">JSFunctionInContext</span></tt></a>)</li>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">convert_to_js_string_arr</tt><big>(</big><em>lst</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#convert_to_js_string_arr"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.convert_to_js_string_arr"title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a Python list (or any iterable) of strings to JS array.</p>
<p><aclass="reference internal"href="#django_select2.util.convert_to_js_arr"title="django_select2.util.convert_to_js_arr"><ttclass="xref py py-func docutils literal"><spanclass="pre">convert_to_js_arr()</span></tt></a> can always be used instead of this. However, since it
knows that it only contains strings, it cuts down on unnecessary computations.</p>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">synchronized</tt><big>(</big><em>f</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#synchronized"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.synchronized"title="Permalink to this definition">¶</a></dt>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">is_valid_id</tt><big>(</big><em>val</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#is_valid_id"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.is_valid_id"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>val</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#str"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">str</span></tt></a>) – The value to check.</td>
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">register_field</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#register_field"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.register_field"title="Permalink to this definition">¶</a></dt>
<dd><p>Registers an Auto field for use with <aclass="reference internal"href="ref_views.html#django_select2.views.AutoResponseView"title="django_select2.views.AutoResponseView"><ttclass="xref py py-class docutils literal"><spanclass="pre">views.AutoResponseView</span></tt></a>.</p>
<li><strong>key</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#unicode"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">unicode</span></tt></a>) – The key to use while registering this field.</li>
<li><strong>field</strong> (<ttclass="xref py py-class docutils literal"><spanclass="pre">AutoViewFieldMixin</span></tt>) – The field to register.</li>
</ul>
</td>
</tr>
<trclass="field-even field"><thclass="field-name">Returns:</th><tdclass="field-body"><pclass="first">The generated Id for this field. If given <ttclass="docutils literal"><spanclass="pre">key</span></tt> was already registered then the
<ttclass="descclassname">django_select2.util.</tt><ttclass="descname">get_field</tt><big>(</big><em>id_</em><big>)</big><aclass="reference internal"href="_modules/django_select2/util.html#get_field"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#django_select2.util.get_field"title="Permalink to this definition">¶</a></dt>
<trclass="field-odd field"><thclass="field-name">Parameters:</th><tdclass="field-body"><strong>id</strong> (<aclass="reference external"href="http://docs.python.org/2.7/library/functions.html#unicode"title="(in Python v2.7)"><ttclass="xref py py-obj docutils literal"><spanclass="pre">unicode</span></tt></a>) – The generated Id the field is registered with.</td>