def home(request, pk): if request.method == 'POST': post = get_object_or_404(Post, id=pk) form = CommentCreateView(request.POST) if form.form_valid(post): form.save() messages.success(request, f'Your comment is posted!') return redirect('post-comments', pk) else: context = { 'post': get_object_or_404(Post, id=pk), 'form': CommentCreateView() } return render(request, 'blog/post_detail.comments.html', context)
ProfileSentView.as_view(), name='profile_sent'), path('accounts/profile/<username>/voted', ProfileVotedView.as_view(), name='profile_voted'), path('accounts/profile/<username>/comments', ProfileCommentsView.as_view(), name='profile_comments'), # links app path('', LinkListView.as_view(), name='link_list'), path('latest/', LinkLatestView.as_view(), name='link_latest'), path('top/', LinkTopView.as_view(), name='link_top'), path('create/', LinkCreateView.as_view(), name='link_create'), path('detail/<pk>', LinkDetailView.as_view(), name='link_detail'), path('update/<pk>', LinkUpdateView.as_view(), name='link_update'), path('delete/<pk>', LinkDeleteView.as_view(), name='link_delete'), # voting app path('vote/<pk>', VoteView.as_view(), name='vote'), # comments app path('detail/<pk>/comment', CommentCreateView.as_view(), name='comment_create'), path('detail/<id>/comment/delete/<pk>', CommentDeleteView.as_view(), name='comment_delete'), path('detail/comment/point/<pk>/', PointView.as_view(), name='point'), ]
from comments.views import CommentCreateView from django.conf.urls import patterns, include, url from django.views.generic import TemplateView from django.contrib import admin __author__ = 'pahaz' urlpatterns = patterns('', url(r'^add$', CommentCreateView.as_view(), name="comments_add"), )
from django.urls import path from comments.views import CommentCreateView, CommentDeleteView, GetLastCommentView, CommentChildCreateView app_name = 'comments' urlpatterns = [ path('create/<int:post_id>', CommentCreateView.as_view(), name='create'), path('<int:post_id>/<int:comment_id>/child/create', CommentChildCreateView.as_view(), name='child_create'), path('delete/<int:comment_id>', CommentDeleteView.as_view(), name='delete'), path('last/<int:post_id>', GetLastCommentView.as_view(), name='last'), ]
#!/usr/bin/env python # encoding: utf-8 ''' @author: kdb @file: urls.py @time: 2018/7/7 0007 上午 11:51 ''' from django.conf.urls import url from comments.views import post_comment,CommentCreateView urlpatterns = [ #url(r'^post_comment/(?P<pk>\d+)/$',post_comment,name='post_comment' ), url(r'^post_comment/(?P<pk>\d+)/$',CommentCreateView.as_view(),name='post_comment' ), ]
from django.urls import path from comments.views import CommentListView, CommentCreateView, CommentDeleteView app_name = 'comments' urlpatterns = [ path('list/<slug:slug>/', CommentListView.as_view(), name='list'), path('delete/<int:pk>/', CommentDeleteView.as_view(), name='delete'), path('create/<int:pk>/', CommentCreateView.as_view(), name='create'), ]