django / django-contrib-comments

BSD 3-Clause "New" or "Revised" License
614 stars 196 forks source link

django_comments , when i add a delete views, it raise dictionary update sequence element #0 has length 1; 2 is required #136

Closed jekoie closed 6 years ago

jekoie commented 6 years ago

i need to add a delete view for my own django_comments view, but it can't work.

comments app structure:
__init__.py   forms.py  migrations/  models.py  urls.py  views.py
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??

claudep commented 6 years ago

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.