Package couchdbkit :: Package ext :: Package django
[hide private]
[frames] | no frames]

Package django

source code

Extension to use couchdbkit in Django 1.x. It allows you to use couchdbkit
easily in your django projects.

Just add to your settings the `COUCHDB_DATABASES` that defines 

            ('djangoapp.greeting', ''),

This one define the db greeting on url ``
for the application `greeting`of djangoapp project.

Then add extension to your INSTALLED_APPS before all applications using
couchdbkit documents :


Add your documents objects in : 

    from couchdbkit.ext.django.schema import *
    class Greeting(Document):
        author = StringProperty()
        content = StringProperty(required=True)
        date = DateTimeProperty(default=datetimee.utcnow)

and use it in your :
    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 = GreetingForm()
        greetings = Greeting.view('greeting/all')
        return render("home.html", {
            "form": form,
            "greet": greet,
            "greetings": greetings
        }, context_instance=RequestContext(request)

You could notice in this example the `DocumentForm` object. 
This object works like the ModelForm object but for couchdb
documents. Very easy.

Views/shows/lists are created in _design folder of your application.
exemple :


To create databases and sync views, just run the usual `syncdb` command.
It won't destroy your datas, just synchronize views.

Submodules [hide private]

Functions [hide private]
syncdb(app, created_models, verbosity=2, **kwargs)
function used by syncdb signal
source code
Variables [hide private]
  __package__ = 'couchdbkit.ext.django'