def message_reply(request, object_id, template_name='messages/message_form.html'):
 original_message = get_object_or_404(Message, pk=object_id)
 next = request.GET.get('next', None)
 initial = {'to_user': original_message.from_user, 'subject': ('Re: %s' % original_message.subject)}
 form = MessageForm((request.POST or None), initial=initial)
 if form.is_valid():
  message = form.save(commit=False)
  message.object = original_message.object
  message.from_user = request.user
  message = form.save()
  return HttpResponseRedirect((next or reverse('messages:messages')))
 return render_to_response(template_name, {'form': form, 'message': original_message, 'next': next}, context_instance=RequestContext(request))

def message_reply ( request , object_id , template_name = 'messages/message_form.html' ) : original_message = get_object_or_404 ( Message , pk = object_id ) next = request . GET . get ( 'next' , None ) initial = { 'to_user' : original_message . from_user , 'subject' : ( 'Re: %s' % original_message . subject ) } form = MessageForm ( ( request . POST or None ) , initial = initial ) if form . is_valid ( ) : message = form . save ( commit = False ) message . object = original_message . object message . from_user = request . user message = form . save ( ) return HttpResponseRedirect ( ( next or reverse ( 'messages:messages' ) ) ) return render_to_response ( template_name , { 'form' : form , 'message' : original_message , 'next' : next } , context_instance = RequestContext ( request ) )
handles a reply to a specific message .