1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

[1.2.X] Fixed #11058 - list_display_links doesn't allow callables not defined in the model

Thanks to dvine for the report and julien for the patch.

Backport of [15619] from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15621 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Luke Plant
2011-02-21 21:20:41 +00:00
parent 25c217bc17
commit 31d0f2fa29
4 changed files with 24 additions and 10 deletions

View File

@@ -778,8 +778,13 @@ class ValidationTests(unittest.TestCase):
ValidationTestModel,
)
def a_callable(obj):
pass
class ValidationTestModelAdmin(ModelAdmin):
list_display = ('name',)
def a_method(self, obj):
pass
list_display = ('name', 'decade_published_in', 'a_method', a_callable)
validate(ValidationTestModelAdmin, ValidationTestModel)
@@ -801,7 +806,7 @@ class ValidationTests(unittest.TestCase):
self.assertRaisesErrorWithMessage(
ImproperlyConfigured,
"'ValidationTestModelAdmin.list_display_links[0]' refers to 'non_existent_field' that is neither a field, method or property of model 'ValidationTestModel'.",
"'ValidationTestModelAdmin.list_display_links[0]' refers to 'non_existent_field' which is not defined in 'list_display'.",
validate,
ValidationTestModelAdmin,
ValidationTestModel,
@@ -812,15 +817,22 @@ class ValidationTests(unittest.TestCase):
self.assertRaisesErrorWithMessage(
ImproperlyConfigured,
"'ValidationTestModelAdmin.list_display_links[0]'refers to 'name' which is not defined in 'list_display'.",
"'ValidationTestModelAdmin.list_display_links[0]' refers to 'name' which is not defined in 'list_display'.",
validate,
ValidationTestModelAdmin,
ValidationTestModel,
)
def a_callable(obj):
pass
class ValidationTestModelAdmin(ModelAdmin):
list_display = ('name',)
list_display_links = ('name',)
def a_method(self, obj):
pass
list_display = ('name', 'decade_published_in', 'a_method', a_callable)
list_display_links = ('name', 'decade_published_in', 'a_method', a_callable)
validate(ValidationTestModelAdmin, ValidationTestModel)