mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #22994 -- regression with generic FK + admin list_view
The reason for the regression was that the GenericForeignKey field isn't something meta.get_field_by_name() should return. The reason is that a couple of places in Django expects get_field_by_name() to work this way. It could make sense to return GFKs from get_field_by_name(), but that should likely be done as part of meta refactoring or virtual fields refactoring patches. Thanks to glicerinu@gmail.com for the report and to Tim for working on the issue.
This commit is contained in:
committed by
Tim Graham
parent
38e001ab6c
commit
9cd5201abd
@@ -1718,11 +1718,26 @@ class AdminViewDeletedObjectsTest(TestCase):
|
||||
"""
|
||||
plot = Plot.objects.get(pk=3)
|
||||
FunkyTag.objects.create(content_object=plot, name='hott')
|
||||
should_contain = """<li>Funky tag: hott"""
|
||||
should_contain = """<li>Funky tag: <a href="/test_admin/admin/admin_views/funkytag/1/">hott"""
|
||||
response = self.client.get('/test_admin/admin/admin_views/plot/%s/delete/' % quote(3))
|
||||
self.assertContains(response, should_contain)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||
ROOT_URLCONF="admin_views.urls")
|
||||
class TestGenericRelations(TestCase):
|
||||
fixtures = ['admin-views-users.xml', 'deleted-objects.xml']
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username='super', password='secret')
|
||||
|
||||
def test_generic_content_object_in_list_display(self):
|
||||
plot = Plot.objects.get(pk=3)
|
||||
FunkyTag.objects.create(content_object=plot, name='hott')
|
||||
response = self.client.get('/test_admin/admin/admin_views/funkytag/')
|
||||
self.assertContains(response, "%s</td>" % plot)
|
||||
|
||||
|
||||
@override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',),
|
||||
ROOT_URLCONF="admin_views.urls")
|
||||
class AdminViewStringPrimaryKeyTest(TestCase):
|
||||
|
||||
Reference in New Issue
Block a user