Example #1
0
def addtopic(request):

    if request.method == 'GET':

        topic = Topic.objects.all()
        return render_to_response('admin/addtopic.html', {'topic': topic})

    if request.method == 'POST':

        bigtopic = request.POST.get('bigtopic')
        success = '操作成功!'
        failure = '发布不成功,请确认信息填充完整后重新发布!'

        topic = Topic()
        topic.bigtopic = bigtopic

        if topic.bigtopic == '':
            return render_to_response('admin/failure.html',
                                      {'failure': failure})

        else:
            topic.save()
            return render_to_response('admin/success.html',
                                      {'success': success})