@handle_response_format
@treeio_login_required
def category_add(request, response_format='html'):
 if request.POST:
  if ('cancel' not in request.POST):
   category = KnowledgeCategory()
   form = KnowledgeCategoryForm(request.POST, instance=category)
   if form.is_valid():
    category = form.save()
    category.set_user_from_request(request)
    return HttpResponseRedirect(reverse('knowledge_category_view', args=[category.treepath]))
  else:
   return HttpResponseRedirect(reverse('knowledge_categories'))
 else:
  form = KnowledgeCategoryForm()
 context = _get_default_context(request)
 context.update({'form': form})
 return render_to_response('knowledge/category_add', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def category_add ( request , response_format = 'html' ) : if request . POST : if ( 'cancel' not in request . POST ) : category = KnowledgeCategory ( ) form = KnowledgeCategoryForm ( request . POST , instance = category ) if form . is_valid ( ) : category = form . save ( ) category . set_user_from_request ( request ) return HttpResponseRedirect ( reverse ( 'knowledge_category_view' , args = [ category . treepath ] ) ) else : return HttpResponseRedirect ( reverse ( 'knowledge_categories' ) ) else : form = KnowledgeCategoryForm ( ) context = _get_default_context ( request ) context . update ( { 'form' : form } ) return render_to_response ( 'knowledge/category_add' , context , context_instance = RequestContext ( request ) , response_format = response_format )
new category form .