Reputation: 3418
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?
Upvotes: 1
Views: 3373
Reputation: 5929
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
Upvotes: 0
Reputation: 3418
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
Upvotes: 0
Reputation: 16346
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.
Upvotes: 1