Python submit and display on one click
I'm new to app engine. With python. My question is: I want to submit and display same record on add button click. As I'm using lightbox to display my records.
My html file: where add button is there.
<td><a href='/display?patients_id={{patient_display.key.id}}&key={{patient_display.key}}' class='display' ><input type="submit" name="submitButtonName" value="Add" id="submitButtonName"></a></td>
My main.py file:
class DisplayAddHandler(webapp.RequestHandler):
def get(self):
self.response.out.write("worksss")
data_key_display = self.request.get('patients_id')
key = self.request.get('key')
patient_print_display = PatientInfo.get_by_id(int(data_key_display),parent=None)
results_print_display = db.GqlQuery("SELECT * FROM PatientMeds WHERE patientinfo_ID=" + data_key_display)
results_patientalerts_print_display = db.GqlQuery("SELECT * FROM PatientAlerts WHERE patientinfo_ID=" + data_key_display)
tem开发者_如何学运维plate_values = {
'patient_display': patient_print_display,
'meds_display': results_print_display,
'alert_display': results_patientalerts_print_display,
}
path = os.path.join(os.path.dirname(__file__), 'display.html')
self.response.out.write(template.render(path, template_values))
Now I want when I save record. It will saved successfully and after saving it will display the record which I have added on one click. (I mean on submit button it will save record + display).
Seems to me you're using Google App Engine, just process form data , insert in db then redirect to your showRecord
page getting id from last row id from cursor
You should divide the page in to two parts. One containing the form and the other to display the records. Use ajax to submit to the datastore and then in ajax's success() function, refresh the div containing records to display the last added record.
精彩评论