Index: django/contrib/admin/options.py =================================================================== --- django/contrib/admin/options.py (revision 11866) +++ django/contrib/admin/options.py (working copy) @@ -585,8 +585,12 @@ 'save_on_top': self.save_on_top, 'root_path': self.admin_site.root_path, }) + if add: + admin_form_template = getattr(self, 'add_form_template', None) + else: + admin_form_template = getattr(self, 'change_form_template', None) context_instance = template.RequestContext(request, current_app=self.admin_site.name) - return render_to_response(self.change_form_template or [ + return render_to_response(admin_form_template or [ "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), "admin/%s/change_form.html" % app_label, "admin/change_form.html" Index: tests/regressiontests/admin_views/tests.py =================================================================== --- tests/regressiontests/admin_views/tests.py (revision 11866) +++ tests/regressiontests/admin_views/tests.py (working copy) @@ -541,12 +541,12 @@ self.failUnlessEqual(request.status_code, 200) self.assert_("var hello = 'Hello!';" in request.content) self.assertTemplateUsed(request, 'custom_admin/change_list.html') - - # Test custom change form template + + # Test custom add form template request = self.client.get('/test_admin/admin/admin_views/customarticle/add/') - self.assertTemplateUsed(request, 'custom_admin/change_form.html') - - # Add an article so we can test delete and history views + self.assertTemplateUsed(request, 'custom_admin/add_form.html') + + # Add an article so we can test delete, change, and history views post = self.client.post('/test_admin/admin/admin_views/customarticle/add/', { 'content': '
great article
', 'date_0': '2008-03-18', @@ -555,7 +555,10 @@ self.assertRedirects(post, '/test_admin/admin/admin_views/customarticle/') self.failUnlessEqual(CustomArticle.objects.all().count(), 1) - # Test custom delete and object history templates + # Test custom delete, change, and object history templates + # Test custom change form template + request = self.client.get('/test_admin/admin/admin_views/customarticle/1/') + self.assertTemplateUsed(request, 'custom_admin/change_form.html') request = self.client.get('/test_admin/admin/admin_views/customarticle/1/delete/') self.assertTemplateUsed(request, 'custom_admin/delete_confirmation.html') request = self.client.get('/test_admin/admin/admin_views/customarticle/1/history/') Index: tests/regressiontests/admin_views/models.py =================================================================== --- tests/regressiontests/admin_views/models.py (revision 11866) +++ tests/regressiontests/admin_views/models.py (working copy) @@ -106,6 +106,7 @@ """ change_list_template = 'custom_admin/change_list.html' change_form_template = 'custom_admin/change_form.html' + add_form_template = 'custom_admin/add_form.html' object_history_template = 'custom_admin/object_history.html' delete_confirmation_template = 'custom_admin/delete_confirmation.html' Index: tests/templates/custom_admin/add_form.html =================================================================== --- tests/templates/custom_admin/add_form.html (revision 0) +++ tests/templates/custom_admin/add_form.html (revision 0) @@ -0,0 +1 @@ +{% extends "admin/change_form.html" %} Index: docs/ref/contrib/admin/index.txt =================================================================== --- docs/ref/contrib/admin/index.txt (revision 11866) +++ docs/ref/contrib/admin/index.txt (working copy) @@ -681,11 +681,20 @@ If you don't specify this attribute, a default template shipped with Django that provides the standard appearance is used. +.. attribute:: ModelAdmin.add_form_template + +Path to a custom template that will be used by the model object creation +views. Templates can override or extend base admin templates as described in +`Overriding Admin Template`_. + +If you don't specify this attribute, a default template shipped with Django +that provides the standard appearance is used. + .. attribute:: ModelAdmin.change_form_template -Path to a custom template that will be used by both the model object creation -and change views. Templates can override or extend base admin templates as -described in `Overriding Admin Templates`_. +Path to a custom template that will be used by the model object change views. +Templates can override or extend base admin templates as described in +`Overriding Admin Templates`_. If you don't specify this attribute, a default template shipped with Django that provides the standard appearance is used.