1
0
mirror of https://github.com/django/django.git synced 2025-10-26 07:06:08 +00:00

[1.5.x] Fixed #17911 -- Ensure that admin readonly fields' display values are shown in change forms when the raw value is None.

Backport of 29d59a879e
This commit is contained in:
Edward Tjörnhammar
2012-11-25 23:13:22 +01:00
committed by Julien Phalip
parent 22ca5bab95
commit 7c91b67cfa
4 changed files with 23 additions and 5 deletions

View File

@@ -46,7 +46,7 @@ from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,
OtherStory, ComplexSortedPerson, Parent, Child, AdminOrderedField,
AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable,
Report, MainPrepopulated, RelatedPrepopulated, UnorderedObject,
Simple, UndeletableObject)
Simple, UndeletableObject, Choice)
ERROR_MESSAGE = "Please enter the correct username and password \
@@ -3202,6 +3202,15 @@ class ReadonlyTest(TestCase):
response = self.client.get('/test_admin/admin2/auth/user/%s/password/' % su.pk)
self.assertEqual(response.status_code, 404)
def test_change_form_renders_correct_null_choice_value(self):
"""
Regression test for #17911.
"""
choice = Choice.objects.create(choice=None)
response = self.client.get('/test_admin/admin/admin_views/choice/%s/' % choice.pk)
self.assertContains(response, '<p>No opinion</p>', html=True)
self.assertNotContains(response, '<p>(None)</p>')
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',))
class RawIdFieldsTest(TestCase):