urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('delete/<int:comment_id>/', views.delete_own_comment, 'delete_own_comment'),
]
views.py:
from django.contrib.auth.views import login_required
from django_comments.views.moderation import perform_delete
from django.shortcuts import get_object_or_404
from django.conf import settings
from .models import CommentModel
@login_required
def delete_own_comment(request, comment_id):
comment = get_object_or_404(CommentModel, id=comment_id, site__pk=settings.SITE_ID)
if comment.user == request.user:
comment.is_removed = True
comment.save()
but when i add the url to main urls, it raise error ValueError: dictionary update sequence element #0 has length 1; 2 is required. so how can add my own delete view or rewrite get_delete_url method??
I guess you should first find help in the Django support channels (IRC, mailing lists) and report again here if you can demonstrate a bug or a possible improvement in django-contrib-comments.
i need to add a delete view for my own django_comments view, but it can't work.
but when i add the url to main urls, it raise error ValueError: dictionary update sequence element #0 has length 1; 2 is required. so how can add my own delete view or rewrite get_delete_url method??