Loading django/contrib/admin/sites.py +2 −2 Original line number Diff line number Diff line Loading @@ -281,7 +281,7 @@ class AdminSite(object): 'site_url': self.site_url, } def password_change(self, request): def password_change(self, request, extra_context=None): """ Handles the "change password" task -- both form display and validation. """ Loading @@ -292,7 +292,7 @@ class AdminSite(object): 'current_app': self.name, 'password_change_form': AdminPasswordChangeForm, 'post_change_redirect': url, 'extra_context': self.each_context(), 'extra_context': dict(self.each_context(), **(extra_context or {})), } if self.password_change_template is not None: defaults['template_name'] = self.password_change_template Loading docs/releases/1.8.txt +3 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ Minor features <django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether or not the full count of objects should be displayed on a filtered admin page. * The ``AdminSite.password_change()`` method now has an ``extra_context`` parameter. :mod:`django.contrib.admindocs` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Loading tests/admin_views/customadmin.py +3 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,9 @@ class Admin2(admin.AdminSite): def my_view(self, request): return HttpResponse("Django is a magical pony!") def password_change(self, request, extra_context=None): return super(Admin2, self).password_change(request, {'spam': 'eggs'}) class UserLimitedAdmin(UserAdmin): # used for testing password change on a user not in queryset Loading tests/admin_views/tests.py +6 −0 Original line number Diff line number Diff line Loading @@ -1012,6 +1012,12 @@ class CustomModelAdminTest(AdminViewBasicTestCase): self.assertTemplateUsed(response, 'custom_admin/password_change_form.html') self.assertContains(response, 'Hello from a custom password change form template') def test_custom_admin_site_password_change_with_extra_context(self): response = self.client.get('/test_admin/admin2/password_change/') self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/password_change_form.html') self.assertContains(response, 'eggs') def test_custom_admin_site_password_change_done_template(self): response = self.client.get('/test_admin/admin2/password_change/done/') self.assertIsInstance(response, TemplateResponse) Loading tests/templates/custom_admin/password_change_form.html +1 −0 Original line number Diff line number Diff line {% extends "registration/password_change_form.html" %} {% block content %} {{ spam }} Hello from a custom password change form template {{ block.super }} {% endblock %} Loading
django/contrib/admin/sites.py +2 −2 Original line number Diff line number Diff line Loading @@ -281,7 +281,7 @@ class AdminSite(object): 'site_url': self.site_url, } def password_change(self, request): def password_change(self, request, extra_context=None): """ Handles the "change password" task -- both form display and validation. """ Loading @@ -292,7 +292,7 @@ class AdminSite(object): 'current_app': self.name, 'password_change_form': AdminPasswordChangeForm, 'post_change_redirect': url, 'extra_context': self.each_context(), 'extra_context': dict(self.each_context(), **(extra_context or {})), } if self.password_change_template is not None: defaults['template_name'] = self.password_change_template Loading
docs/releases/1.8.txt +3 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ Minor features <django.contrib.admin.ModelAdmin.show_full_result_count>` to control whether or not the full count of objects should be displayed on a filtered admin page. * The ``AdminSite.password_change()`` method now has an ``extra_context`` parameter. :mod:`django.contrib.admindocs` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Loading
tests/admin_views/customadmin.py +3 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,9 @@ class Admin2(admin.AdminSite): def my_view(self, request): return HttpResponse("Django is a magical pony!") def password_change(self, request, extra_context=None): return super(Admin2, self).password_change(request, {'spam': 'eggs'}) class UserLimitedAdmin(UserAdmin): # used for testing password change on a user not in queryset Loading
tests/admin_views/tests.py +6 −0 Original line number Diff line number Diff line Loading @@ -1012,6 +1012,12 @@ class CustomModelAdminTest(AdminViewBasicTestCase): self.assertTemplateUsed(response, 'custom_admin/password_change_form.html') self.assertContains(response, 'Hello from a custom password change form template') def test_custom_admin_site_password_change_with_extra_context(self): response = self.client.get('/test_admin/admin2/password_change/') self.assertIsInstance(response, TemplateResponse) self.assertTemplateUsed(response, 'custom_admin/password_change_form.html') self.assertContains(response, 'eggs') def test_custom_admin_site_password_change_done_template(self): response = self.client.get('/test_admin/admin2/password_change/done/') self.assertIsInstance(response, TemplateResponse) Loading
tests/templates/custom_admin/password_change_form.html +1 −0 Original line number Diff line number Diff line {% extends "registration/password_change_form.html" %} {% block content %} {{ spam }} Hello from a custom password change form template {{ block.super }} {% endblock %}