diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-04-19 10:16:25 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-04-19 10:16:25 +0000 |
| commit | c3dbe9d50991cd749491633787c529b101fa04be (patch) | |
| tree | 3ab00c230a334086307a4aa5da27725b04c5b4d9 | |
| parent | 1ad9c36fb8cba9e2687b2ebb2d69ed4ccef58885 (diff) | |
Fixed #13361 - Made sure jQuery is always included in the admin changelist and changeform. Thanks to Carl Meyer for report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12997 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/admin/options.py | 5 | ||||
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 8 | ||||
| -rw-r--r-- | tests/regressiontests/admin_views/tests.py | 8 |
3 files changed, 19 insertions, 2 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 1d3a15048e..531ce4d9b7 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -271,9 +271,10 @@ class ModelAdmin(BaseModelAdmin): def _media(self): from django.conf import settings - js = ['js/core.js', 'js/admin/RelatedObjectLookups.js'] + js = ['js/core.js', 'js/admin/RelatedObjectLookups.js', + 'js/jquery.min.js', 'js/jquery.init.js'] if self.actions is not None: - js.extend(['js/jquery.min.js', 'js/jquery.init.js', 'js/actions.min.js']) + js.extend(['js/actions.min.js']) if self.prepopulated_fields: js.append('js/urlify.js') js.append('js/prepopulate.min.js') diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index c779b3ca6d..aa16cf2a5f 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -938,6 +938,14 @@ on your ``ModelAdmin``:: Keep in mind that this will be prepended with ``MEDIA_URL``. The same rules apply as :ref:`regular media definitions on forms <topics-forms-media>`. +Django admin Javascript makes use of the `jQuery`_ library. To avoid +conflict with user scripts, 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. + +.. _jQuery: http://jquery.com + Adding custom validation to the admin ------------------------------------- diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py index f15f61781a..abb28de38b 100644 --- a/tests/regressiontests/admin_views/tests.py +++ b/tests/regressiontests/admin_views/tests.py @@ -1386,6 +1386,14 @@ class AdminActionsTest(TestCase): self.assert_('action-checkbox-column' not in response.content, "Found unexpected action-checkbox-column class in response") + def test_model_without_action_still_has_jquery(self): + "Tests that a ModelAdmin without any actions still gets jQuery included in page" + response = self.client.get('/test_admin/admin/admin_views/oldsubscriber/') + self.assertEquals(response.context["action_form"], None) + self.assert_('jquery.min.js' in response.content, + "jQuery missing from admin pages for model with no admin actions" + ) + def test_action_column_class(self): "Tests that the checkbox column class is present in the response" response = self.client.get('/test_admin/admin/admin_views/subscriber/') |
