@handle_response_format
@treeio_login_required
def account_add(request, response_format='html'):
 if request.POST:
  if ('cancel' not in request.POST):
   account = Account()
   form = AccountForm(request.user.profile, request.POST, instance=account)
   if form.is_valid():
    account = form.save(commit=False)
    convert(account, 'balance')
    account.set_user_from_request(request)
    return HttpResponseRedirect(reverse('finance_account_view', args=[account.id]))
  else:
   return HttpResponseRedirect(reverse('finance_index_accounts'))
 else:
  form = AccountForm(request.user.profile)
 return render_to_response('finance/account_add', {'form': form}, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def account_add ( request , response_format = 'html' ) : if request . POST : if ( 'cancel' not in request . POST ) : account = Account ( ) form = AccountForm ( request . user . profile , request . POST , instance = account ) if form . is_valid ( ) : account = form . save ( commit = False ) convert ( account , 'balance' ) account . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'finance_account_view' , args = [ account . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'finance_index_accounts' ) ) else : form = AccountForm ( request . user . profile ) return render_to_response ( 'finance/account_add' , { 'form' : form } , context_instance = RequestContext ( request ) , response_format = response_format )
new account form .