/ / अजैक्स के माध्यम से बुलाया पायथन फ़ंक्शन 'परिभाषित नहीं है' - पायथन, एजैक्स, डीजेंगो, एक्सएक्सएक्सएक्सपीटर

अजैक्स के माध्यम से पाइथन समारोह को परिभाषित नहीं किया गया है '- पायथन, अजैक्स, डीजेंगो, xlsxwriter

मैं पायथन फ़ंक्शन का उपयोग कर रहा हूंXlsxWriter मेरे Django ऐप में अजाक्स के माध्यम से उत्कृष्टता प्राप्त करने के लिए कुछ डेटा लिखने के लिए। मैंने इस फ़ंक्शन को कॉल करने के लिए अपने एक बटन की ऑनक्लिक विधि को बांधने के लिए jQuery का उपयोग किया। हालाँकि, जब मैं इसे कॉल करता हूं, तो Django मुझे एक त्रुटि देता है जो कहता है कि "ExportHistoExcel परिभाषित नहीं है"। यह मुझे भ्रमित कर रहा है क्योंकि एक ही स्क्रिप्ट में मेरे अन्य सभी कार्य पहचाने जाते हैं और चल रहे हैं, लेकिन एक कारण किसी कारण के लिए "t" नहीं है। क्या कोई मेरी मदद कर सकता है?

यहाँ मेरी अजगर स्क्रिप्ट है:

from xlsxwriter.workbook import Workbook

def exportHistoExcel(SE_filelocation, VTfile_location, filename):

print("anything?")
#new getFiringRates return statement:
#    if generating_excel_file: return [bins, spikeanglebins, headanglebins, times, firingrates]
#   else: return True
#new getFiringRates parameter:
#   generating_excel_file = False

data = getFiringRates(SE_filelocation, VTfile_location, generating_excel_file = True)
print(data)

workbook = Workbook(filename)
worksheet = workbook.add_worksheet()
worksheet.write("A1", "Bin (degrees)")
worksheet.write("B1", "# of Spikes")
worksheet.write("C1", "# of Samples")
worksheet.write("D1", "Time (sec)")
worksheet.write("E1", "Firing Rate")

worksheet.write_column("A2", data[0])
worksheet.write_column("B2", data[1])
worksheet.write_column("C2", data[2])
worksheet.write_column("D2", data[3])
worksheet.write_column("E2", data[4])
worksheet.write("A62", 360); worksheet.write("B62", "=$B$2")
worksheet.write("C62", "=$C$2"); worksheet.write("D62", "=$D$2");   worksheet.write("E62", "=$E$2")


histo = workbook.add_chart({"type": "line"})
histo.set_title({"name": "Firing Rates"})
histo.set_x_axis({"name": "Bin (degrees)"})
histo.set_y_axis({"name": "Firing rate (sec^-1)"})
histo.add_series({"values": "=Sheet1!$E$2:$E$61",
"line": {"color": "black"},
"categories": "=Sheet1!$A$2:$A$61"})
histo.set_legend({"delete_series": [0]})
worksheet.insert_chart("F2", histo)


workbook.close()

और यहाँ मेरी ajax.py फ़ाइल है:

from django.utils import simplejson
from dajaxice.decorators import dajaxice_register
from hipercic.apps.NeuroCiC import models
from django.core.files import storage
import file_analysis
import sys

@dajaxice_register
def export_excel_file(request, id):
print "TRIAL ID", id

try:
trial = models.Trial.objects.get(pk=id)
except:
"Could not find trial."
else:
print "Found Trial"
print("~/hipercic/apps/NeuroCiC/uploads/" + trial.spikes_file.url)
SE_loc = "~/hipercic/apps/NeuroCiC/uploads/" + trial.spikes_file.url
VT_loc = "~/hipercic/apps/NeuroCiC/uploads/" + trial.led_file.url
print(SE_loc)
print(VT_loc)
exportHistoExcel(SE_loc, VT_loc, "demo.xlsx")
return

अजाक्स में प्रिंट स्टेटमेंट्स टर्मिनल पर सभी प्रिंटिंग कर रहे हैं, लेकिन एक्सपोर्टहिटोसेल में सभी नहीं हैं क्यों isn "यह मेरे अजगर समारोह को पहचान रहा है?

उत्तर:

उत्तर № 1 के लिए 1

जब मैंने बदला तो यह काम कर रहा था

exportHistoExcel(SE_loc, VT_loc, "demo.xlsx")

इसके लिए लाइन:

return simplejson.dumps({"scatter_data": file_analysis.exportHistoExcel("test.xlsx") })