Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added notes on jQuery

  • Loading branch information...
commit b708ea825c8555ab7b9b761dba19c43c6a81b756 1 parent 9f9a7f0
@evildmp authored
Showing with 25 additions and 5 deletions.
  1. +25 −5 docs/ref/contrib/admin/index.txt
View
30 docs/ref/contrib/admin/index.txt
@@ -1380,15 +1380,35 @@ The :doc:`staticfiles app </ref/contrib/staticfiles>` prepends
``None``) to any media paths. The same rules apply as :ref:`regular media
definitions on forms <form-media-paths>`.
-Django admin Javascript makes use of the `jQuery`_ library. To avoid
-conflicts with user-supplied scripts or libraries, Django's jQuery is
+Django admin Javascript makes use of the `jQuery`_ library.
+
+To avoid conflicts with user-supplied scripts or libraries, Django's jQuery is
namespaced as ``django.jQuery``. If you want to use jQuery in your own admin
JavaScript without including a second copy, you can use the ``django.jQuery``
object on changelist and add/edit views.
-If you require the jQuery library to be in the global namespace, for example
-when using third-party jQuery plugins, or need a newer version of jQuery, you
-will have to include your own copy of jQuery.
+The ``BaseModelAdmin`` superclass loads jQuery by default. There is no need to
+add jQuery to your ``ModelAdmin``'s list of required media resources just
+because it needs jQuery. In fact it is recommended *not* to; it's unnecessary,
+and could result in both ``jquery.js`` and ``jquery.min.js`` being loaded (see
+`Uncompressed and 'minified' jQuery`_.).
+
+It's also generally recommended that you make use of ``jquery.js`` as provided
+by Django, rather than calling in your own version.
+
+However, if you require the jQuery library to be in the global namespace, for
+example when using third-party jQuery plugins, or need a newer version of
+jQuery, you will have to include your own copy of jQuery.
+
+Uncompressed and 'minified' jQuery
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Django provides both uncompressed and 'minified' versions of jQuery, as
+``jquery.js`` and ``jquery.min.js`` respectively.
+
+The ``BaseModelAdmin`` superclass has a ``media`` property that returns a list
+of media files' URLS to the form. If :setting:`DEBUG` is ``True`` it will return
+the uncompressed versions of various JavaScript files, including ``jquery.js``;
+if not, it will return the 'minified' versions.
.. _jQuery: http://jquery.com
Please sign in to comment.
Something went wrong with that request. Please try again.