Ticket #13004: catch_error_with_test-12818.diff
File catch_error_with_test-12818.diff, 2.2 KB (added by , 15 years ago) |
---|
-
django/contrib/admin/helpers.py
154 154 field, obj, model_admin = self.field, self.form.instance, self.model_admin 155 155 try: 156 156 f, attr, value = lookup_field(field, obj, model_admin) 157 except (AttributeError, ObjectDoesNotExist):157 except (AttributeError, ValueError, ObjectDoesNotExist): 158 158 result_repr = EMPTY_CHANGELIST_VALUE 159 159 else: 160 160 if f is None: -
tests/regressiontests/admin_views/tests.py
1986 1986 p = Post.objects.order_by('-id')[0] 1987 1987 self.assertEqual(p.posted, datetime.date.today()) 1988 1988 1989 def test_readonly_manytomany(self): 1990 "Regression test for #13004" 1991 response = self.client.get('/test_admin/admin/admin_views/pizza/add/') 1992 self.assertEqual(response.status_code, 200) 1993 1989 1994 class IncompleteFormTest(TestCase): 1990 1995 """ 1991 1996 Tests validation of a ModelForm that doesn't explicitly have all data -
tests/regressiontests/admin_views/models.py
565 565 def __unicode__(self): 566 566 return self.name 567 567 568 class Topping(models.Model): 569 name = models.CharField(max_length=20) 570 571 class Pizza(models.Model): 572 name = models.CharField(max_length=20) 573 toppings = models.ManyToManyField('Topping') 574 575 class PizzaAdmin(admin.ModelAdmin): 576 readonly_fields = ('toppings',) 577 568 578 admin.site.register(Article, ArticleAdmin) 569 579 admin.site.register(CustomArticle, CustomArticleAdmin) 570 580 admin.site.register(Section, save_as=True, inlines=[ArticleInline]) … … 609 619 admin.site.register(Book, inlines=[ChapterInline]) 610 620 admin.site.register(Promo) 611 621 admin.site.register(ChapterXtra1) 622 admin.site.register(Pizza, PizzaAdmin) 623 admin.site.register(Topping)