404 Error Passing A "Alert" Sentence From Python To Html Page, But No Error For Passing Just A Word
Update: The error message I get with the sentence is 404 Resource not found. 'GET /unexpected/The%20Notebook%20name%20is%20taken%20already HTTP/1.1' 404 - The URL looks like this
Solution 1:
My problem is that I am trying to do this in def get(
without a datastore model to transfer information to the def get(
. I have defined a def get(
that uses a datastore model named Trans
that stores such transactional information that is contained in my sentence in a variable named reason
.
class Trans(db.Model):
reason = db.StringProperty()
My model named Unexpected
looks like the following.
class Unexpected(BaseHandler):
def get(self):
trans=Trans.get_by_key_name('reason')
template_values = {'trans':trans}
path = os.path.join(TEMPLATE_DIR, 'unexpected.html')
self.response.out.write(template.render(path, template_values))
And my python codes is as follows.
reason='That Notebook name is taken already.'
trans = Trans(key_name='reason')
trans.reason=reason
trans.put()
template_values = {'trans':trans}
path = os.path.join(TEMPLATE_DIR, 'unexpected.html')
self.response.out.write(template.render(path, template_values))
My unexpected.html
code follows.
{% extends "base.html" %}
{% block content %}
This unexpected result occurred: <emph style="font-weight: bold">{{ trans.reason }}</emph>
<br /><br />
<label>Click the "Ok" button and to go back to the previous page so you can edit your entry .
</label>
<form action="" method="post">
<input type="hidden" name="reason" value=""></input><br />
<input type="submit" value="Ok"/>
</form>
{% endblock content %}
Post a Comment for "404 Error Passing A "Alert" Sentence From Python To Html Page, But No Error For Passing Just A Word"