def thread_dir(request, forum_id): thread_list = Thread.objects.filter(forum=forum_id) forum_info = Forum.objects.get(id=forum_id) if request.method == "POST": # If the form has been submitted... form = ThreadForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass forum = Thread(forum=forum_info) form = ThreadForm(request.POST, instance=forum) form.save() return HttpResponseRedirect(reverse("forum.views.thread_dir", args=(forum_id,))) else: form = ThreadForm() # An unbound form return render_to_response( "forum/thread.html", {"thread_list": thread_list, "forum_info": forum_info, "form": form}, context_instance=RequestContext(request), )
def thread_dir(request, forum_id): thread_list = Thread.objects.filter(forum=forum_id) forum_info = Forum.objects.get(id=forum_id) if request.method == "POST": form = ThreadForm(request.POST) thread = form.save(commit=False) thread.utilisateur = request.user thread.forum = forum_info thread.save() return HttpResponseRedirect(reverse("forum.views.thread_dir", args=(forum_id,))) else: form = ThreadForm() return render_to_response( "forum/thread.html", {"thread_list": thread_list, "forum_info": forum_info, "form": form}, context_instance=RequestContext(request), )