@login_required
def create(request):
    if (request.method != 'POST'):
        return render(request, 'guestbook/create.html', context=locals())
    title = request.POST['title']
    content = request.POST['content']
    istitle = Guestbook.objects.filter(title=title)
    if istitle:
        messages.info(request, (('告警：标题 ' + title) + '已经被使用！'))
        return HttpResponseRedirect('/guestbook/show/')
    if content:
        guestbooks = Guestbook(username=request.user, title=title, content=content)
        guestbooks.save()
        guestbookname = Guestbook.objects.get(title=title).username
        replys = Reply(guestbookname=guestbookname, title=title)
        replys.save()
    else:
        messages.info(request, '告警：留言内容为空！')
    return HttpResponseRedirect('/guestbook/show/')
@login_required
def create(request):
    if (request.method != 'POST'):
        return render(request, 'guestbook/create.html', context=locals())
    title = request.POST['title']
    content = request.POST['content']
    istitle = Guestbook.objects.filter(title=title)
    if istitle:
        messages.info(request, (('告警：标题 ' + title) + '已经被使用！'))
        return HttpResponseRedirect('/guestbook/show/')
    if content:
        guestbooks = Guestbook(username=request.user, title=title, content=content)
        guestbooks.save()
        guestbookname = Guestbook.objects.get(title=title).username
        replys = Reply(guestbookname=guestbookname, title=title)
        replys.save()
    else:
        messages.info(request, '告警：留言内容为空！')
    return HttpResponseRedirect('/guestbook/show/')