def sections(request): if request.method == 'POST': # save new post heading = request.POST['heading'] content = request.POST['content'] section = Section(heading=heading) section.heading = heading # section.content = cgi.escape(content).encode("ascii", "xmlcharrefreplace") section.content = content section.save() # Get all sections from DB sections = Section.objects return render_to_response('admin/index.html', {'Sections': sections}, context_instance=RequestContext(request))