I want to call generate_pic from my views.py with some pass-in parameters
In views.py I have:
def msa_result(request, measurement_id):
try:
print measurement_id
_measurement = UserMeasurements.objects.get(measurement_id=measurement_id)
import MySQLdb
db = MySQLdb.connect(host="10.231.XX.XX", localhost
port=3306,
user="XXX",
passwd="XXX",
db="XX")
print "connect database successfully"
processing_dict = {'set_id': measurement_id }
from post_processing import generate_pic
result = generate_pic(db, processing_dict)
if result=='success' :
return render(request, 'msa_result.html', {'measurement': _measurement})
else:
raise Http404("Can not process image in post_processing.py")
except:
raise Http404("oh noooooo @msa_result")
The HTML page's error is "oh noooooo @msa_result" but not "Can not process image in post_processing.py"
in post_proccessing.py I have:
def generate_pic(db, **kwargs):
print "I an here" #this never print out
if kwargs['set_id']:
user = kwargs.get('user', 'no_user')
set_id = kwargs['set_id']
set_id = int(set_id)
return 'success'
else:
return "Please give a set_id to process result."
views.py and post_processing.py are in the same folder.
What's wrong with my code?