开发者

Couchdbkit: name 'DocumentForm' is not defined in django. How do I include and use it?

开发者 https://www.devze.com 2023-03-08 19:30 出处:网络
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'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 = Stri开发者_如何学运维ngProperty()
    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.


It's in couchdbkit.ext.django.forms, as you could have found by looking through the code.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号