def newstory(request): if request.POST['title'] and request.POST['content']: p=Story(title=request.POST['title'], content=request.POST['content']) p.save() return HttpResponseRedirect(reverse('index')) else: return render(request,'storys/index.html',{ 'story_list': Story.objects.all(), 'error_message':"Please write somthing and try again.",})