def topicPage(request, topic_title):
try:
topic = Topic.getTopic(topic_title)
except Topic.DoesNotExist:
raise Http404()
# edit topic form
if request.method == 'POST':
if not request.user.is_superuser:
return HttpResponseForbidden()
form = TopicForm(request.POST, instance=topic)
if form.is_valid():
form.save()
return redirect('topicPage', topic.urlTitle)
showForm = True
else:
form = TopicForm(instance=topic)
showForm = False
threads = Thread.objects.filter(topic=topic)
context = dict(topic=topic, threads=threads, showCreatedBy=True, showTopic=False, topicForm=form, showForm=showForm)
return render(request, 'djeddit/topic.html', context)
评论列表
文章目录