#11058: list_display_links doesn't allow callables not defined in the model
-------------------------------------------+--------------------------------
Reporter: dvine | Owner: nobody
Status: new | Milestone:
Component: django.contrib.admin | Version: 1.0
Resolution: | Keywords:
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------------+--------------------------------
Comment (by akaihola):
If all (or most of) fields displayed are editable, it makes sense to have
an "Edit" link.
Here's how we can display an initial "Edit" column with links to change
forms for each row:
{{{
def list_display_column_factory(value, title=None):
column = lambda result: value
column.short_description = title or value
return column
class PollAdmin(admin.ModelAdmin):
model = Poll
edit_column = list_display_column_factory(_(u'Edit'))
list_display = (edit_column, 'question', 'pub_date')
list_editable = ('question', 'pub_date')
}}}
But if we want to move the "Edit" column to another position or introduce
another link column, this won't work:
{{{
list_display = ('question', 'pub_date', edit_column)
list_editable = ('pub_date', )
list_display_links = ('question', edit_column,)
}}}
It throws this exception:
{{{
[...]
File "polls/admin.py", line 16, in <module>
admin.site.register(Poll, PollAdmin)
File "django/contrib/admin/sites.py", line 92, in register
validate(admin_class, model)
File "django/contrib/admin/validation.py", line 50, in validate
fetch_attr(cls, model, opts, 'list_display_links[%d]' % idx, field)
File "django/contrib/admin/validation.py", line 308, in fetch_attr
return getattr(model, field)
TypeError: getattr(): attribute name must be string
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/11058#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---