def plan_comment_add(request, *args, **kwargs): goal = args[0] plan = args[1] comment = Comment(plan = plan) form = CommentForm(request.POST, instance = comment) if form.is_valid(): comment = form.save(commit = False) comment.ip = request.META.get('REMOTE_ADDR') comment.user_agent = request.META.get('HTTP_USER_AGENT') comment.save() return HttpResponseRedirect( '%s?msg=%s' % ( reverse( 'user_plan_logbook', args = [goal.slug, plan.user.username] ), 'Your comment is awaiting approval.' ) ) return render_to_response( 'plan/error.html', { 'goal': goal, 'user': plan.user, 'plan': plan }, RequestContext(request) )