Ticket #10640: add_form.diff
File add_form.diff, 4.9 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/options.py
585 585 'save_on_top': self.save_on_top, 586 586 'root_path': self.admin_site.root_path, 587 587 }) 588 if add: 589 admin_form_template = getattr(self, 'add_form_template', None) 590 else: 591 admin_form_template = getattr(self, 'change_form_template', None) 588 592 context_instance = template.RequestContext(request, current_app=self.admin_site.name) 589 return render_to_response( self.change_form_template or [593 return render_to_response(admin_form_template or [ 590 594 "admin/%s/%s/change_form.html" % (app_label, opts.object_name.lower()), 591 595 "admin/%s/change_form.html" % app_label, 592 596 "admin/change_form.html" -
tests/regressiontests/admin_views/tests.py
541 541 self.failUnlessEqual(request.status_code, 200) 542 542 self.assert_("var hello = 'Hello!';" in request.content) 543 543 self.assertTemplateUsed(request, 'custom_admin/change_list.html') 544 545 # Test custom changeform template544 545 # Test custom add form template 546 546 request = self.client.get('/test_admin/admin/admin_views/customarticle/add/') 547 self.assertTemplateUsed(request, 'custom_admin/ change_form.html')548 549 # Add an article so we can test delete and history views547 self.assertTemplateUsed(request, 'custom_admin/add_form.html') 548 549 # Add an article so we can test delete, change, and history views 550 550 post = self.client.post('/test_admin/admin/admin_views/customarticle/add/', { 551 551 'content': '<p>great article</p>', 552 552 'date_0': '2008-03-18', … … 555 555 self.assertRedirects(post, '/test_admin/admin/admin_views/customarticle/') 556 556 self.failUnlessEqual(CustomArticle.objects.all().count(), 1) 557 557 558 # Test custom delete and object history templates 558 # Test custom delete, change, and object history templates 559 # Test custom change form template 560 request = self.client.get('/test_admin/admin/admin_views/customarticle/1/') 561 self.assertTemplateUsed(request, 'custom_admin/change_form.html') 559 562 request = self.client.get('/test_admin/admin/admin_views/customarticle/1/delete/') 560 563 self.assertTemplateUsed(request, 'custom_admin/delete_confirmation.html') 561 564 request = self.client.get('/test_admin/admin/admin_views/customarticle/1/history/') -
tests/regressiontests/admin_views/models.py
106 106 """ 107 107 change_list_template = 'custom_admin/change_list.html' 108 108 change_form_template = 'custom_admin/change_form.html' 109 add_form_template = 'custom_admin/add_form.html' 109 110 object_history_template = 'custom_admin/object_history.html' 110 111 delete_confirmation_template = 'custom_admin/delete_confirmation.html' 111 112 -
tests/templates/custom_admin/add_form.html
1 {% extends "admin/change_form.html" %} -
docs/ref/contrib/admin/index.txt
681 681 If you don't specify this attribute, a default template shipped with Django 682 682 that provides the standard appearance is used. 683 683 684 .. attribute:: ModelAdmin.add_form_template 685 686 Path to a custom template that will be used by the model object creation 687 views. Templates can override or extend base admin templates as described in 688 `Overriding Admin Template`_. 689 690 If you don't specify this attribute, a default template shipped with Django 691 that provides the standard appearance is used. 692 684 693 .. attribute:: ModelAdmin.change_form_template 685 694 686 Path to a custom template that will be used by both the model object creation687 and change views. Templates can override or extend base admin templates as 688 described in`Overriding Admin Templates`_.695 Path to a custom template that will be used by the model object change views. 696 Templates can override or extend base admin templates as described in 697 `Overriding Admin Templates`_. 689 698 690 699 If you don't specify this attribute, a default template shipped with Django 691 700 that provides the standard appearance is used.