def new_institution(request): if request.POST: new_institution = NewInstitution(request.POST) if new_institution.is_valid(): institution = new_institution.save() json = serializers.serialize('json',[institution]) return HttpResponse(json, mimetype='application/json'); else: new_institution = NewInstitution() return render_to_response('repository/new_institution.html', {'form':new_institution})
def new_institution(request): if request.POST: new_institution = NewInstitution(request.POST) if new_institution.is_valid(): institution = new_institution.save(commit=False) institution.creator = request.user institution.save() json = serializers.serialize('json',[institution]) return HttpResponse(json, mimetype='application/json') else: return HttpResponse(new_institution.as_table(), mimetype='text/html') else: new_institution = NewInstitution() return render_to_response('repository/new_institution.html', {'form':new_institution}, context_instance=RequestContext(request))