App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
List of all members
google.appengine.ext.db.djangoforms.ModelForm Class Reference
Inheritance diagram for google.appengine.ext.db.djangoforms.ModelForm:
google.appengine.ext.db.djangoforms.BaseModelForm

Additional Inherited Members

- Public Member Functions inherited from google.appengine.ext.db.djangoforms.BaseModelForm
def __init__
 
def save
 
- Public Attributes inherited from google.appengine.ext.db.djangoforms.BaseModelForm
 instance
 

Detailed Description

A Django form tied to a Datastore model.

Note that this particular class just sets the metaclass; all other
functionality is defined in the base class, BaseModelForm, above.

Usage example:

  from google.appengine.ext import db
  from google.appengine.ext.db import djangoforms

  # First, define a model class
  class MyModel(db.Model):
    foo = db.StringProperty()
    bar = db.IntegerProperty(required=True, default=42)

  # Now define a form class
  class MyForm(djangoforms.ModelForm):
    class Meta:
      model = MyModel

You can now instantiate MyForm without arguments to create an
unbound form, or with data from a POST request to create a bound
form.  You can also pass a model instance with the instance=...
keyword argument to create an unbound (!) form whose initial values
are taken from the instance.  For bound forms, use the save() method
to return a model instance.

Like Django's own corresponding ModelForm class, the nested Meta
class can have two other attributes:

  fields: if present and non-empty, a list of field names to be
          included in the form; properties not listed here are
          excluded from the form

  exclude: if present and non-empty, a list of field names to be
           excluded from the form

If exclude and fields are both non-empty, names occurring in both
are excluded (i.e. exclude wins).  By default all property in the
model have a corresponding form field defined.

It is also possible to define form fields explicitly.  This gives
more control over the widget used, constraints, initial value, and
so on.  Such form fields are not affected by the nested Meta class's
fields and exclude attributes.

If you define a form field named 'key_name' it will be treated
specially and will be used as the value for the key_name parameter
to the Model constructor. This allows you to create instances with
named keys. The 'key_name' field will be ignored when updating an
instance (although it will still be shown on the form).

The documentation for this class was generated from the following file: