Couchdbkit:名称“DocumentForm” django 中没有定义。我如何包含和使用它?
我想开始使用 couchdbkit,但我遇到了一个主要的障碍。提供的示例代码对我不起作用。
我不断收到错误消息,指出名称“DocumentForm”未定义。
中的代码
from couchdbkit.ext.django.schema import *
class Greeting(Document):
author = StringProperty()
content = StringProperty(required=True)
这是模型和视图
from poly.learn.models import Greeting
class GreetingForm(DocumentForm):
class Meta:
document = Greeting
def home(request):
greet = None
if request.POST:
form = GreetingForm(request.POST)
if form.is_valid():
greet = form.save()
else:
form = GreetingForm()
greetings = Greeting.view('greeting/all')
return render("home.html", {
"form": form,
"greet": greet,
"greetings": greetings
}, context_instance=RequestContext(request))
看起来我需要包含并使用另一个类。有谁知道它在哪里吗?
谢谢。
I'd like to start using couchdbkit but I have come across a major stumbling block. The example code provided isn't working for me.
I keep getting an error saying that the name 'DocumentForm' is not defined.
Here is the code from the model
from couchdbkit.ext.django.schema import *
class Greeting(Document):
author = StringProperty()
content = StringProperty(required=True)
and view
from poly.learn.models import Greeting
class GreetingForm(DocumentForm):
class Meta:
document = Greeting
def home(request):
greet = None
if request.POST:
form = GreetingForm(request.POST)
if form.is_valid():
greet = form.save()
else:
form = GreetingForm()
greetings = Greeting.view('greeting/all')
return render("home.html", {
"form": form,
"greet": greet,
"greetings": greetings
}, context_instance=RequestContext(request))
It looks like I need to include and use another class. Does anyone know where it is?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它位于
couchdbkit.ext.django.forms
中,您可以通过查看代码找到它。It's in
couchdbkit.ext.django.forms
, as you could have found by looking through the code.