views.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:django-djeddit 作者: EatEmAll 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号