Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Simple models and views to work with couchbase in django applications.

Project Description

Django Couchbase

Django Couchbase is a wrapper around `couchbase <>`_
python library plus several hook to
`Sync-Gateway <>`_ API.

The document search is perfomred using ``couchbase`` library (directly) connection
to `couchbase server <>`_,
but saving and retrieving of the document is done using
`Sync-Gateway HTTP API <>`_. This is done in order to have documents available for mobile
clients, which can get all benefits of ``couchbase`` library only through Sync-Gateway.

The essential part of the package is models. They are inherited from django models
with almost all the benefits they have: can be validated with django forms and have fields
all sort of field you are used to have.



* working Couchbase server / cluster
* working Sync-Gateway server


* ``couchbase==2.0.2``
* ``django-extensions==1.5.5``
* ``django-tastypie==0.12.2``
* ``requests==2.7.0``
* ``shortuuid==0.4.2``

``couchbase`` package installation can be tricky. A recipe for Ubuntu 12::

sudo wget -O/etc/apt/sources.list.d/couchbase.list

wget -O- | sudo apt-key add -

sudo apt-get update

sudo apt-get install libcouchbase-dev libcouchbase2-libevent

Quick Install

Install package::

pip install git+

The following configuration settings are used for the package (you can use the set below for the fast installation)::

COUCHBASE_DESIGN = 'django_couchbase'
SYNC_GATEWAY_USER = "django_couchbase_admin"
SYNC_GATEWAY_PASSWORD = "django_couchbase_admin_password"
SYNC_GATEWAY_GUEST_USER = "django_couchbase_guest"
SYNC_GATEWAY_GUEST_PASSWORD = "django_couchbase_guest_password"

For more detals for settings see :ref:`ref-settings`.

Add ``django_couchbase`` to ``INSTALLED_APPS``::

# ...

Create folder ``couchbase_views`` in the project root.


You should create a testing couchbase bucket to run the package tests
(and further your apps tests). For example ``django_couchbase_test``.

The testing bucket must contain ``test`` in the name. Otherwise some
helper functions will raise exception.

Certianly SyncGateway configuration must also have to be configurated properly
to take in account additional bucket, for example::

"databases": {
"default": {
"server": "",
"bucket": "default"
"django_couchbase_test": {
"server": "",
"bucket": "django_couchbase_test"

Also you need an alternative ```` to run tests. Probably you already have
similar file to run your own tests. If you don't it's time to create it now.
The following settings should be changed in order to run Couchbase-related tests properly::

1. ``COUCHBASE_BUCKET`` is targetted to test bucket
1. ``SYNC_GATEWAY_BUCKET`` is targetted to test bucket
2. ``COUCHBASE_STALE`` is set to disable Couchbase caching

Like that, in file ````::

# ...
COUCHBASE_BUCKET = 'django_couchbase_test'
SYNC_GATEWAY_BUCKET = 'django_couchbase_test'
# ...

You will have to have at least one view-file in ``couchbase_views`` folder, ``by_channel.js``::

function (doc, meta) {
if (doc.st_deleted) {
for (channel in doc.channels) {
emit([doc.channels[channel], doc.doc_type], null)

Now run tests as usual for django::

python test --settings=<your-project>.test_settings django_couchbase

Release History

This version
History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(25.0 kB) Copy SHA256 Hash SHA256
Source Oct 15, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting