English 中文(简体)
公认会计原则模板将表格作为html的案文而不是形式。
原标题:GAE template renders form as html text rather than the form

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?

问题回答

我不熟悉Kinja,因为根据Jinja2号文件,它似乎因违约而逃避所有超文本处理。

从上看你的模板来看,我发现你正在使用事件表上的越狱过滤器,我无法找到关于金贾这种过滤器的信息。 如果你希望以超文本形式提供这种表格,那么我们为什么需要逃脱?

{-活动>

http://jinja.pocoo.org/docs/api/#autoescaping”rel=“nofollow”>http://jinja.pocoo.org/docs/api/#autoescaping





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签