Wagtail Comments admin menu returns 500 at /cms/snippets/comments/comment/ #37
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Opening Comments from the Wagtail admin menu routes to
/cms/snippets/comments/comment/and returns HTTP 500.Reproduction
/cms/snippets/comments/comment/.Confirmed locally with:
Root cause
CommentViewSet.list_displayinapps/comments/wagtail_hooks.pyincludes"pending_in_article"as a string:Wagtail resolves string columns via Django admin
label_for_fieldagainst the model (Comment).Commenthas no model field/attribute namedpending_in_article, so Wagtail raises:FieldDoesNotExist: Comment has no field named 'pending_in_article'AttributeError: Unable to lookup 'pending_in_article' on CommentThe
pending_in_articlemethod defined on the viewset is not used by this lookup path.Proposed solution
Use an explicit table column object for the annotated value instead of a string list_display entry.
Suggested code change
apps/comments/wagtail_hooks.py:Columnfromwagtail.admin.ui.tables."pending_in_article"inlist_displaywithColumn("pending_in_article", label="Pending (article)").pending_in_articleviewset method andshort_descriptionassignment.Regression test
Add an admin view test that logs in a superuser and requests
/cms/snippets/comments/comment/, asserting200 OK.This catches future list_display misconfigurations that only fail during Wagtail column construction.
Impact