0

GoogleAppEngineでWTFormを使用しています。クラスとして自分のフォームにアクセスしたい。

これはdjangoformsで動作します...

class PostForm(djangoforms.ModelForm):
  class Meta:
    model = BlogPost
    exclude = [ 'path', 'published', 'updated' ]

WTformsで同等の方法を実行するにはどうすればよいですか。

class PostForm(model_form):
  class Meta:
    model = BlogPost
    exclude = [ 'path', 'published', 'updated' ]

トレースバックでこのエラーが発生します...

    Traceback (most recent call last):
  File "C:\Users\John\webdev\gae\google\appengine\runtime\wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "C:\Users\John\webdev\gae\google\appengine\runtime\wsgi.py", line 225, in _LoadHandler
    handler = __import__(path[0])
  File "C:\Users\John\webdev\gae\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Users\John\webdev\gae\google\appengine\tools\dev_appserver_import_hook.py", line 1858, in load_module
    return self.FindAndLoadModule(submodule, fullname, search_path)
  File "C:\Users\John\webdev\gae\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Users\John\webdev\gae\google\appengine\tools\dev_appserver_import_hook.py", line 1722, in FindAndLoadModule
    description)
  File "C:\Users\John\webdev\gae\google\appengine\tools\dev_appserver_import_hook.py", line 676, in Decorate
    return func(self, *args, **kwargs)
  File "C:\Users\John\webdev\gae\google\appengine\tools\dev_appserver_import_hook.py", line 1665, in LoadModuleRestricted
    description)
  File "C:\Users\John\webdev\gae-projects\cmwo-blog\admin.py", line 69, in <module>
    class PostForm(model_form):
TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str
INFO     2012-07-30 14:40:31,700 dev_appserver.py:2952] "GET /admin/newpost HTTP/1.1" 500 -
4

1 に答える 1

1

WTFormsのmodel_formは、Meta内部クラスを処理しません。'__init__'たぶん、PostFormクラスのメソッドをオーバーライドすることができます。

于 2012-07-31T07:05:14.467 に答える