djangoforms を使うとき

GAE の djangoforms を使うときの話。 Django を使ってる人には関係ないお話。

get_form_field 等を使うことで簡単に拡張ができます。

# vim: fileencoding=utf8

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

from models import Account, Status

class AccountForm(djangoforms.ModelForm):
  user = djangoforms.UserProperty().get_form_field(initial=None, label='Email')
  class Meta:
    model = Account
    exclude = ['user', 'created']

class StatusForm(djangoforms.ModelForm):
  class Meta:
    model = Status
    exclude = ['account', 'created']