Reputation: 1
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)
template_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).
Upvotes: 0
Views: 312
Reputation: 5842
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.
Upvotes: 0