views:

227

answers:

1

Here are model and form classes from example:

http://code.google.com/appengine/articles/djangoforms.html

class Item(db.Model):
  name = db.StringProperty()
  quantity = db.IntegerProperty(default=1)
  target_price = db.FloatProperty()
  priority = db.StringProperty(default='Medium',choices=[
    'High', 'Medium', 'Low'])
  entry_time = db.DateTimeProperty(auto_now_add=True)
  added_by = db.UserProperty()

class ItemForm(djangoforms.ModelForm):
  class Meta:
    model = Item
    exclude = ['added_by']

It will be rendered as table rows.

Can I change how they will be rendered (change width or make it to be list instead of table row or anything…)?

+1  A: 

Take a look at the Django forms docs, here. The docs are for 1.0, but most of it applies to the 0.91 version bundled with App Engine, too.

The short answer to your question: form.as_p will generate an HTML representation of the form as a series of <p> tags, while form.as_ul will generate a series of <ul> tags and form.as_table will generate a table.

Nick Johnson
Thanks I realized that I've used ModelForm instead of just forms/newforms.
Oleksandr Bolotov
Are there any forms/newforms inside google.appengine.ext or I must use "from django import newforms" ?
Oleksandr Bolotov
The latter. The modules in appengine.ext are stuff that was written by Google - some of interacts with Django.
Nick Johnson
And you can continue to use ModelForm - as_p, etc should work fine with it.
Nick Johnson