def create_reply(request, topic_id): if request.method == 'POST': t = topic.objects.get(id=topic_id) r = post() r.topic = t if request.POST['content']: r.content = request.POST['content'] else: return error(request,'请填写内容') r.user = request.user r.save() return HttpResponseRedirect(reverse('topic_view', kwargs={'topic_id': t.id})) elif request.method == 'GET': return error(request,'don\'t get')
def create_reply(request, topic_id): if request.method == 'POST': t = topic.objects.get(id=topic_id) r = post() r.topic = t if request.POST['content']: r.content = request.POST['content'] else: messages.add_message(request, messages.WARNING, _('content cannot be empty')) return HttpResponseRedirect(reverse('topic_view', kwargs={'topic_id':topic_id})) r.user = request.user r.save() return HttpResponseRedirect(reverse('topic_view', kwargs={'topic_id': t.id})) elif request.method == 'GET': return error(request, 'don\'t get')
def create_reply(request, topic_id): if request.method == 'POST': t = topic.objects.get(id=topic_id) r = post() r.topic = t if request.POST['content']: r.content = request.POST['content'] else: messages.add_message(request, messages.WARNING, u'请填写内容') return HttpResponseRedirect( reverse('topic_view', kwargs={'topic_id': topic_id})) r.user = request.user r.save() return HttpResponseRedirect( reverse('topic_view', kwargs={'topic_id': t.id})) elif request.method == 'GET': return error(request, 'don\'t get')