def showtopic(request, gurl_number, turl_number): group = Group.objects(url_number=gurl_number).get() topic = Topic.objects(url_number=turl_number).get() topic.clicks += 1 topic.save() if request.method == "POST": form = NewPostForm(request.POST) if form.is_valid(): content = form.cleaned_data["content"] post = Post(content=content) post.author = request.user post.creat_time = datetime.datetime.now() post.floor = Post.objects(topic=topic).count() + 1 post.topic = topic post.is_active = True post.save() topic.update_author = request.user topic.update_time = datetime.datetime.now() topic.save() return HttpResponseRedirect("/group/" + str(gurl_number) + "/topic/" + str(turl_number) + "/") else: form = NewPostForm() return render_to_response( "group/group_topic.html", {"group": group, "current_user": request.user, "form": form, "topic": topic, "STATIC_URL": STATIC_URL}, context_instance=RequestContext(request), )