I am working through the GoogleAppEngine Event example and I m trying to build a form that I can enter event data
from google.appengine.ext.db import djangoforms
class Event(db.Model):
title = db.StringProperty(required=True)
description = db.TextProperty()
time = db.DateTimeProperty()
location = db.TextProperty()
creator = db.UserProperty()
class EventForm(djangoforms.ModelForm):
class Meta:
model = Event
class EventsPage(webapp.RequestHandler):
def get(self):
eventform = EventForm()
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = Logout
else:
url = users.create_login_url(self.request.uri)
url_linktext = Login
template_values = {
events : events,
eventform : eventform,
url : url,
url_linktext : url_linktext,
}
template = jinja_environment.get_template( events.html )
self.response.out.write(template.render(template_values))
----events.html----
<html>
<head>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
</head>
<body>
{% for event in events %}
<blockquote>{{ event.content|escape }}</blockquote>
{% endfor %}
<form action="/newevent" method="post">
<!-- Even though <table> is below, event form is not put inside <table>. Why?? -->
<table>
{{ eventform|escape }}
</table>
<div><input type="submit" value="New Event"></div>
</form>
<a href="{{ url }}">{{ url_linktext }}</a>
</body>
</html>
在我管理我的法典时,以下内容在我的网页上作为文本:
<tr><th><label for="id_title">Title:</label></th><td><input type="text"
name="title" id="id_title" /></td></tr> <tr><th><label
for="id_description">Description:</label></th><td><textarea id="id_description"
rows="10" cols="40" name="description"></textarea></td></tr> <tr><th><label
for="id_time">Time:</label></th><td><input type="text" name="time" id="id_time"
/></td></tr> <tr><th><label
for="id_location">Location:</label></th><td><textarea id="id_location"
rows="10" cols="40" name="location"></textarea></td></tr> <tr><th><label
for="id_creator">Creator:</label></th><td><input type="text" name="creator"
id="id_creator" /></td></tr>
I can tell this is table code and I want to the page to render as a tabular form, not as text. Any ideas why this is happening? And how to make it render as a form?