#encoding utf-8 from django.shortcuts import render from django.shortcuts import render_to_response, get_object_or_404 from django.http import HttpResponse, HttpResponseRedirect from models import Campos from django.template import RequestContext from django.template import * from django.views.decorators.csrf import csrf_exempt # Create your views here. @csrf_exempt def index(request): if request.method == 'POST': #print("entros") var = request.POST.get('archivoupload') #print var fields = ['cdrRecordType', 'globalCallID_callManagerId', 'globalCallID_callId', 'origLegCallIdentifier', 'dateTimeOrigination', 'origNodeId', 'origSpan', 'origIpAddr', 'callingPartyNumber', 'callingPartyUnicodeLoginUserID', 'origCause_location', 'origCause_value', 'origPrecedenceLevel', 'origMediaTransportAddress_IP', 'origMediaTransportAddress_Port', 'origMediaCap_payloadCapability', 'origMediaCap_maxFramesPerPacket', 'origMediaCap_g723BitRate', 'origVideoCap_Codec', 'origVideoCap_Bandwidth', 'origVideoCap_Resolution', 'origVideoTransportAddress_IP', 'origVideoTransportAddress_Port', 'origRSVPAudioStat', 'origRSVPVideoStat', 'destLegIdentifier', 'destNodeId', 'destSpan', 'destIpAddr', 'originalCalledPartyNumber', 'finalCalledPartyNumber', 'finalCalledPartyUnicodeLoginUserID', 'destCause_location', 'destCause_value', 'destPrecedenceLevel', 'destMediaTransportAddress_IP', 'destMediaTransportAddress_Port', 'destMediaCap_payloadCapability', 'destMediaCap_maxFramesPerPacket', 'destMediaCap_g723BitRate', 'destVideoCap_Codec', 'destVideoCap_Bandwidth', 'destVideoCap_Resolution', 'destVideoTransportAddress_IP', 'destVideoTransportAddress_Port', 'destRSVPAudioStat', 'destRSVPVideoStat', 'dateTimeConnect', 'dateTimeDisconnect', 'lastRedirectDn', 'pkid', 'originalCalledPartyNumberPartition', 'callingPartyNumberPartition', 'finalCalledPartyNumberPartition', 'lastRedirectDnPartition', 'duration', 'origDeviceName', 'destDeviceName', 'origCallTerminationOnBehalfOf', 'destCallTerminationOnBehalfOf', 'origCalledPartyRedirectOnBehalfOf', 'lastRedirectRedirectOnBehalfOf', 'origCalledPartyRedirectReason', 'lastRedirectRedirectReason', 'destConversationId', 'globalCallId_ClusterID', 'joinOnBehalfOf', 'comment', 'authCodeDescription', 'authorizationLevel', 'clientMatterCode', 'origDTMFMethod', 'destDTMFMethod', 'callSecuredStatus', 'origConversationId', 'origMediaCap_Bandwidth', 'destMediaCap_Bandwidth', 'authorizationCodeValue', 'outpulsedCallingPartyNumber', 'outpulsedCalledPartyNumber', 'origIpv4v6Addr', 'destIpv4v6Addr', 'origVideoCap_Codec_Channel2', 'origVideoCap_Bandwidth_Channel2', 'origVideoCap_Resolution_Channel2', 'origVideoTransportAddress_IP_Channel2', 'origVideoTransportAddress_Port_Channel2', 'origVideoChannel_Role_Channel2', 'destVideoCap_Codec_Channel2', 'destVideoCap_Bandwidth_Channel2', 'destVideoCap_Resolution_Channel2', 'destVideoTransportAddress_IP_Channel2', 'destVideoTransportAddress_Port_Channel2', 'destVideoChannel_Role_Channel2', 'incomingProtocolID', 'incomingProtocolCallRef', 'outgoingProtocolID', 'outgoingProtocolCallRef', 'currentRoutingReason', 'origRoutingReason', 'lastRedirectingRoutingReason', 'huntPilotDN', 'huntPilotPartition', 'calledPartyPatternUsage', 'outpulsedOriginalCalledPartyNumber', 'outpulsedLastRedirectingNumber', 'wasCallQueued', 'totalWaitTimeInQueue', 'callingPartyNumber_uri', 'originalCalledPartyNumber_uri', 'finalCalledPartyNumber_uri', 'lastRedirectDn_uri'] f = open(var) datos = f.read() import string lista = string.split(datos, '\n') pares = map(lambda e: string.split(e, ','), lista) for row in pares: Campos.objects.create(**dict(zip(fields,row))) #print row #html="

Los Datos se Estan Almacenando

" #jquery = row #contexto = {'variable':jquery} return render_to_response('base2.html',context_instance=RequestContext(request)) '''def base(request): sa ="Hola" ctx = {'saludo':sa} return render_to_response('base2.html',ctx,context_instance=RequestContext(request))''' def base2(request): return TemplateResponse('base.html')