webapp2、ndbモデルを使用しています。
私はndbモデルでdjangoモデルフォームを使おうとしていました。以下は私のセットアップからの関連部分です:
app.yaml:
libraries:
- name: webapp2
version: "2.5.1"
- name: jinja2
version: latest
- name: markupsafe
version: latest
- name: django
version: 1.3
Models.py:
class SubTask(ndb.Model):
task = ndb.StructuredProperty(TaskList)
description = ndb.TextProperty()
start_time = ndb.DateTimeProperty()
end_time = ndb.DateTimeProperty()
Forms.py:
from django.forms import ModelForm
from models import TaskList, TaskCategory, SubTask
class SubTaskForm(ModelForm):
class Meta:
model = SubTask
ハンドラ:
class CreateSubTask(BaseHandler):
def get(self):
self.render_template('index.html', {'form':SubTaskForm})
app = webapp2.WSGIApplication([('/', IndexPage),
('/subtask', CreateSubTask), ],
debug=True)
私が得るエラーは次のとおりです: AttributeError:タイプオブジェクト'SubTask'には属性'_meta'がありません
私の質問: ndbでdjangoモデルフォームを使用する方法はありますか?それとも、間違えた場合はどうなりますか?django modelformsでない場合、ndbモデルはWTFormsで正常に機能しますか?
以下に添付されているのはスタックトレースです。
ERROR 2012-06-23 03:25:58,770 wsgi.py:189]
Traceback (most recent call last):
File "/homeproject/expts/google_appengine/google/appengine/runtime/wsgi.py", line 187, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/homeproject/expts/google_appengine/google/appengine/runtime/wsgi.py", line 225, in _LoadHandler
handler = __import__(path[0])
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1858, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1722, in FindAndLoadModule
description)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1665, in LoadModuleRestricted
description)
File "/homeproject/expts/google_appengine/tdl/main.py", line 18, in <module>
from views import IndexPage, CreateSubTask
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1858, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1722, in FindAndLoadModule
description)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1665, in LoadModuleRestricted
description)
File "/homeproject/expts/google_appengine/tdl/views.py", line 4, in <module>
from forms import SubTaskForm
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1858, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1722, in FindAndLoadModule
description)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 676, in Decorate
return func(self, *args, **kwargs)
File "/homeproject/expts/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1665, in LoadModuleRestricted
description)
File "/homeproject/expts/google_appengine/tdl/forms.py", line 4, in <module>
class SubTaskForm(ModelForm):
File "/homeproject/expts/google_appengine/lib/django_1_3/django/forms/models.py", line 205, in __new__
opts.exclude, opts.widgets, formfield_callback)
File "/homeproject/expts/google_appengine/lib/django_1_3/django/forms/models.py", line 145, in fields_for_model
opts = model._meta
AttributeError: type object 'SubTask' has no attribute '_meta'