Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added notes on jQuery

  • Loading branch information...
commit b708ea825c8555ab7b9b761dba19c43c6a81b756 1 parent 9f9a7f0
Daniele Procida authored

Showing 1 changed file with 25 additions and 5 deletions. Show diff stats Hide diff stats

  1. +25 5 docs/ref/contrib/admin/index.txt
30 docs/ref/contrib/admin/index.txt
@@ -1380,15 +1380,35 @@ The :doc:`staticfiles app </ref/contrib/staticfiles>` prepends
1380 1380 ``None``) to any media paths. The same rules apply as :ref:`regular media
1381 1381 definitions on forms <form-media-paths>`.
1382 1382
1383   -Django admin Javascript makes use of the `jQuery`_ library. To avoid
1384   -conflicts with user-supplied scripts or libraries, Django's jQuery is
  1383 +Django admin Javascript makes use of the `jQuery`_ library.
  1384 +
  1385 +To avoid conflicts with user-supplied scripts or libraries, Django's jQuery is
1385 1386 namespaced as ``django.jQuery``. If you want to use jQuery in your own admin
1386 1387 JavaScript without including a second copy, you can use the ``django.jQuery``
1387 1388 object on changelist and add/edit views.
1388 1389
1389   -If you require the jQuery library to be in the global namespace, for example
1390   -when using third-party jQuery plugins, or need a newer version of jQuery, you
1391   -will have to include your own copy of jQuery.
  1390 +The ``BaseModelAdmin`` superclass loads jQuery by default. There is no need to
  1391 +add jQuery to your ``ModelAdmin``'s list of required media resources just
  1392 +because it needs jQuery. In fact it is recommended *not* to; it's unnecessary,
  1393 +and could result in both ``jquery.js`` and ``jquery.min.js`` being loaded (see
  1394 +`Uncompressed and 'minified' jQuery`_.).
  1395 +
  1396 +It's also generally recommended that you make use of ``jquery.js`` as provided
  1397 +by Django, rather than calling in your own version.
  1398 +
  1399 +However, if you require the jQuery library to be in the global namespace, for
  1400 +example when using third-party jQuery plugins, or need a newer version of
  1401 +jQuery, you will have to include your own copy of jQuery.
  1402 +
  1403 +Uncompressed and 'minified' jQuery
  1404 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1405 +Django provides both uncompressed and 'minified' versions of jQuery, as
  1406 +``jquery.js`` and ``jquery.min.js`` respectively.
  1407 +
  1408 +The ``BaseModelAdmin`` superclass has a ``media`` property that returns a list
  1409 +of media files' URLS to the form. If :setting:`DEBUG` is ``True`` it will return
  1410 +the uncompressed versions of various JavaScript files, including ``jquery.js``;
  1411 +if not, it will return the 'minified' versions.
1392 1412
1393 1413 .. _jQuery: http://jquery.com
1394 1414

0 comments on commit b708ea8

Please sign in to comment.
Something went wrong with that request. Please try again.