try: call = Call.objects.get( event_num__iexact = row[ "EventNum" ].strip() ) action = "UPDATE" except: call = Call() action = "INSERT" call.description = row[ "Description" ] call.event_num = row[ "EventNum" ] call.report_num = row[ "ReportNum" ] call.response = row[ "Response" ] call.address = row[ "Address" ] call.zip_code = row[ "Zip" ] call.call_time = row[ "CallTime" ] call.call_type = call_type call.calltype_id = call_type.id call.beat = beat if ( row[ "Lng" ] is not None or row[ "Lng" ] != "" ) and ( row[ "Lat" ] is not None or row[ "Lng" ] != "" ): try: call.geom = fromstr('POINT(' + row[ "Lng"] + " " + row[ "Lat" ] +')', srid=4326) except: print "ERROR setting the geometry! for %s" % row[ "EventNum" ] call.jurisdiction = juri call.save() #print dir( call ) count +=1 print "%d: %s: %s" % (count, action, row["EventNum"])