On Fri, Oct 17, 2008 at 3:21 PM, Ty <[EMAIL PROTECTED]> wrote: > > # admin.py: > from django.contrib import admin > from clydefrog.blog.models import Post, Comment > > class PostAdmin(admin.ModelAdmin): > list_display = ('name', 'slug', 'date', 'is_published',) > list_filter = ('is_published',) > ordering = ('is_published', '-date', 'name',) > search_fields = ['name', 'raw_body',] > > class CommentAdmin(admin.ModelAdmin): > list_display = ('name', 'email', 'website', 'date', 'approved', > 'is_admin',) > list_filter = ('approved', 'is_admin',) > ordering = ('-date','name',) > search_fields = ['raw_body','name','email','website',] > > admin.site.register(Post, PostAdmin) > admin.site.register(Comment, CommentAdmin) > > ------------------------------------------------------------------ > > Hey everyone. This is working perfectly for me, however I'd like to > display what post each comment belongs to in the comment > administration list. > > I've tried something like this but I can't get anything working: > list_display = ('Post.name', 'name', 'email', 'website', 'date', > 'approved', 'is_admin',) > > Is this currently possible? >
Certainly. Here's the doc on what you can put in list_display: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#list-display If the __unicode__ method of the Post model displays its name, then you simply add the name of the ForeignKey field for Post in Comment and you'll get what you were looking for by trying 'Post.name'. If Post's __unicode__ method isn't what you want to see, write a method on the CommentAdmin model that returns what you want to see and include it in list_display. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---