Extending the Django change list view to include the object title it is related to -
I am using the Django Comments Framework to allow comments on articles in a blog The comment (comment) that I want to display is in the list view of the comment section where the comment's name, content type, object id etc. is to be displayed.
How do I do this? I know that you can hook up the actions in your admin or list view by typing a model method, but in this situation I do not have a model for comments because I am using the built-in one.
Thanks
Anywhere in your code, you can override the comments ModelAdmin class and do whatever you want to do They can expand it. This code has not been tested, but you should give a general enough idea about how to customize the comment admin: django.contrib Import admin from django.contrib.comments.admin admin admin class MyCommentsAdmin (CommentsAdmin ): # This is the list that will call list_display def show_object_title (self): return self.content_object.title list_display = super (MyCommentsAdmin, itself) .list_display list_display + = ('show_object_title',) admin.site.unregister (comment) Admin.site.register (Comment, MyCommentsAdmin)
Comments
Post a Comment