@handle_response_format
@treeio_login_required
def document_add(request, response_format='html'):
 if request.POST:
  if ('cancel' not in request.POST):
   document = Document()
   form = DocumentForm(request.user.profile, None, request.POST, instance=document)
   if form.is_valid():
    document = form.save()
    document.set_user_from_request(request)
    return HttpResponseRedirect(reverse('documents_document_view', args=[document.id]))
  else:
   return HttpResponseRedirect(reverse('document_index'))
 else:
  form = DocumentForm(request.user.profile, None)
 context = _get_default_context(request)
 context.update({'form': form})
 return render_to_response('documents/document_add', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def document_add ( request , response_format = 'html' ) : if request . POST : if ( 'cancel' not in request . POST ) : document = Document ( ) form = DocumentForm ( request . user . profile , None , request . POST , instance = document ) if form . is_valid ( ) : document = form . save ( ) document . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'documents_document_view' , args = [ document . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'document_index' ) ) else : form = DocumentForm ( request . user . profile , None ) context = _get_default_context ( request ) context . update ( { 'form' : form } ) return render_to_response ( 'documents/document_add' , context , context_instance = RequestContext ( request ) , response_format = response_format )
new document form .