django-comments 添加一个新的 url 和一个评论视图?

django-comments add a new url and a view for comments?

我比较新,正在学习 django.when 我安装了 django_comments,我需要添加新的 url 并查看 django_comments,但它不起作用.

comments folder structure:
__init__.py  __pycache__/  forms.py  migrations/  models.py  templates/  urls.py  views.py

__init__.py:
def get_model():
    from comments.models import CommentModel
    return CommentModel

def get_form():
    from comments.forms import CommentForm
    return CommentForm

和 forms.py 和 models.py 很好 work.but 当我添加 urls.py、views.py 并将 url 添加到主 urls文件。它不起作用。

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 .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()

但是当我将 path('mycomments/', include('comments.urls')) 添加到主 urls.py 时,它会出现 运行 奇怪的错误。谁能帮帮我???

不是

django-admin startapp myapp

python manage.py startapp myapp

前提是你之前创建的项目有

django-admin startproject myproject