1

I'm using django.contrib.comments for allowing users to comment on a blog. How is it possible to make the comments display on the Django Admin /admin/comments/comment/ and make them clickable for editing?

[Here should be an image, but since this is my first question and I have no credit, it is not allowed to include images]

The comments can be accessed via /admin/comments/comment/comment_id/ and edited without problems.

Any ideas how to get that solved?

Meilo
  • 3,378
  • 3
  • 28
  • 34

3 Answers3

1

Looking at django.contrib.comments.admin, it should be already visible in your admin panel, provided you added 'django.contrib.comments' to INSTALLED_APPS.

EDIT:

Second look at admin.py from Comments app revelaed that CommentsAdmin.list_display doesn't contain the comment itself. So I would either inherit from that CommentsAdmin, override list_display and then unregister and re-register Comment with MyNewCommentsAdmin - or I would just monkey-patch CommentsAdmin. Whichever works.

Tomasz Zieliński
  • 16,136
  • 7
  • 59
  • 83
  • Thanks for your answer, Tomasz. Yes, the comments are available in the admin panel, they can be sorted by date, etc. However, the admin panel displays only the number of comments; there is no link displayed to the individual comments so that they can be edited easily. Any idea how the individual comments can be made visible? Somebody who had a similar issue with the admin panel before? – Meilo Nov 09 '10 at 20:36
  • Take a look at my edited answer. For me it's not as issue with the admin panel, just the way that CommentsAdmin has been designed. – Tomasz Zieliński Nov 10 '10 at 09:58
0

add to answer Meilo:

if you use standard comment's framework (like: #in url.py

url(r'^comments/', include('django.contrib.comments.urls')),

you wish overwrite behavior comments model, you need import

#apps.admin.py

from django.contrib.comments.models import Comment
madjardi
  • 5,649
  • 2
  • 37
  • 37
0

Thank you Tomasz, The problem was 'content_type' in list_display, which resulted in nothing at all displayed. Removing it from MyCommentsAdmin resolved the problem:

app/admin.py:

class MyCommentsAdmin(admin.ModelAdmin):
    fieldsets = (
        (_('Content'),
           {'fields': ('user', 'user_name', 'user_email', 'user_url', 'comment')}
        ),
        (_('Metadata'),
           {'fields': ('submit_date', 'ip_address', 'is_public', 'is_removed')}
        ),
     )

    list_display = ('name', 'ip_address', 'submit_date', 'is_public', 'is_removed')
    list_filter = ('submit_date', 'site', 'is_public', 'is_removed')
    date_hierarchy = 'submit_date'
    ordering = ('-submit_date',)
    raw_id_fields = ('user',)
    search_fields = ('comment', 'user__username', 'user_name', 'user_email', 'user_url', 'ip_address')

admin.site.unregister(Comment)
admin.site.register(Comment, MyCommentsAdmin)

urls.py:

from django.contrib import admin
admin.autodiscover()

import app.admin
Meilo
  • 3,378
  • 3
  • 28
  • 34