Skip to content

Commit

Permalink
added notes on jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
evildmp committed Jan 11, 2013
1 parent 9f9a7f0 commit b708ea8
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions docs/ref/contrib/admin/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b708ea8

Please sign in to comment.