Ticket #16433: django-16433-with-test.patch
File django-16433-with-test.patch, 3.3 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/util.py
304 304 def help_text_for_field(name, model): 305 305 try: 306 306 help_text = model._meta.get_field_by_name(name)[0].help_text 307 except models.FieldDoesNotExist:307 except (models.FieldDoesNotExist, AttributeError): 308 308 help_text = "" 309 309 return smart_unicode(help_text) 310 310 -
tests/regressiontests/admin_views/admin.py
411 411 def get_changelist(self, request, **kwargs): 412 412 return CustomChangeList 413 413 414 class ToppingAdmin(admin.ModelAdmin): 415 readonly_fields = ('pizzas',) 414 416 415 417 class PizzaAdmin(admin.ModelAdmin): 416 418 readonly_fields = ('toppings',) … … 630 632 site.register(Promo) 631 633 site.register(ChapterXtra1, ChapterXtra1Admin) 632 634 site.register(Pizza, PizzaAdmin) 633 site.register(Topping )635 site.register(Topping, ToppingAdmin) 634 636 site.register(Album, AlbumAdmin) 635 637 site.register(Question) 636 638 site.register(Answer) -
tests/regressiontests/admin_views/tests.py
42 42 FoodDelivery, RowLevelChangePermissionModel, Paper, CoverLetter, Story, 43 43 OtherStory, ComplexSortedPerson, Parent, Child, AdminOrderedField, 44 44 AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable, 45 Report, MainPrepopulated, RelatedPrepopulated, UnorderedObject )45 Report, MainPrepopulated, RelatedPrepopulated, UnorderedObject, Pizza, Topping) 46 46 47 47 48 48 ERROR_MESSAGE = "Please enter the correct username and password \ … … 3104 3104 response = self.client.get('/test_admin/admin2/auth/user/%s/password/' % su.pk) 3105 3105 self.assertEquals(response.status_code, 404) 3106 3106 3107 def test_readonly_backwards_ref(self): 3108 """Regression test for #16433 - backwards references for related objects 3109 break if the related field is read-only - due to the .help_text attribute 3110 """ 3111 topping = Topping.objects.create(name='Salami') 3112 pizza = Pizza.objects.create(name='Americano') 3113 pizza.toppings.add(topping) 3114 response = self.client.get('/test_admin/admin/admin_views/topping/add/') 3115 self.assertEqual(response.status_code, 200) 3107 3116 3117 3108 3118 class RawIdFieldsTest(TestCase): 3109 3119 urls = "regressiontests.admin_views.urls" 3110 3120 fixtures = ['admin-views-users.xml'] -
tests/regressiontests/admin_views/models.py
455 455 class Topping(models.Model): 456 456 name = models.CharField(max_length=20) 457 457 458 459 458 class Pizza(models.Model): 460 459 name = models.CharField(max_length=20) 461 toppings = models.ManyToManyField('Topping' )460 toppings = models.ManyToManyField('Topping', related_name='pizzas') 462 461 463 462 464 463 class Album(models.Model):