如何在Django Admin中显示注释?

如何在Django Admin中显示注释?,django,django-comments,Django,Django Comments,我使用django.contrib.comments允许用户在博客上发表评论。 如何使注释显示在Django Admin/Admin/comments/comment/上,并使其可单击进行编辑 [这里应该有一张图片,但由于这是我的第一个问题,我没有信用,因此不允许包含图片] 可以通过/admin/comments/comment/comment\u id/访问评论,并对其进行编辑 有什么办法解决这个问题吗?查看django.contrib.comments.admin,如果您在已安装的应用程序中

我使用django.contrib.comments允许用户在博客上发表评论。 如何使注释显示在Django Admin/Admin/comments/comment/上,并使其可单击进行编辑

[这里应该有一张图片,但由于这是我的第一个问题,我没有信用,因此不允许包含图片]

可以通过/admin/comments/comment/comment\u id/访问评论,并对其进行编辑


有什么办法解决这个问题吗?

查看django.contrib.comments.admin,如果您在已安装的应用程序中添加了“django.contrib.comments”,它应该已经在您的管理面板中可见

编辑:


第二,从评论应用Reveed查看admin.py,它不包含评论本身。所以我要么继承那个CommentsAdmin,覆盖列表显示,然后取消注册,并用MyNewCommentsAdmin重新注册评论,要么我只是对CommentsAdmin进行修补。无论哪种方法有效。

查看django.contrib.comments.admin,如果您在已安装的应用程序中添加了“django.contrib.comments”,它应该已经在您的管理面板中可见

编辑:

第二,从评论应用Reveed查看admin.py,它不包含评论本身。所以我要么继承那个CommentsAdmin,覆盖列表显示,然后取消注册,并用MyNewCommentsAdmin重新注册评论,要么我只是对CommentsAdmin进行修补。无论哪一个有效。

谢谢你,托马斯, 问题是列表显示中的“内容类型”,这导致根本没有显示任何内容。从MyCommentsAdmin中删除它解决了以下问题:

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)
URL.py:

from django.contrib import admin
admin.autodiscover()

import app.admin
谢谢你,托马斯, 问题是列表显示中的“内容类型”,这导致根本没有显示任何内容。从MyCommentsAdmin中删除它解决了以下问题:

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)
URL.py:

from django.contrib import admin
admin.autodiscover()

import app.admin
要回答Meilo,请添加以下内容:

如果使用标准注释的框架(如:url.py中的#)

url(r'^comments/', include('django.contrib.comments.urls')),
如果要覆盖行为注释模型,则需要导入

#apps.admin.py

from django.contrib.comments.models import Comment
要回答Meilo,请添加以下内容:

如果使用标准注释的框架(如:url.py中的#)

url(r'^comments/', include('django.contrib.comments.urls')),
如果要覆盖行为注释模型,则需要导入

#apps.admin.py

from django.contrib.comments.models import Comment

谢谢你的回答,Tomasz。是的,评论可以在管理面板中找到,可以按日期等进行排序。但是,管理面板只显示评论的数量;没有显示个人评论的链接,因此可以轻松编辑。知道如何使个人评论可见吗?有sim卡的人以前管理面板的ilar问题?看看我编辑过的答案。对我来说,这不是管理面板的问题,只是CommentsAdmin的设计方式。谢谢你的回答,Tomasz。是的,评论可以在管理面板中找到,它们可以按日期排序,等等。但是,管理面板只显示评论的数量;没有显示个人评论的链接,因此可以轻松编辑。知道如何显示个人评论吗?以前有人对管理面板有类似问题吗?看看我编辑的答案。对我来说,这不是管理面板的问题,只是CommentsAdmin的设计方式。