Package: django-cbtools
Django CBToolsDjango CBTools is a wrapper aroundCouchbasepython library plus several hook toSync-GatewayAPI.The document search is done usingCouchbaselibrary (directly) connection
tocouchbase server,
but saving and retrieving of the document is done usingSync-Gateway HTTP API. This is done in order to have documents available for mobile
clients, which can get all benefits ofCouchbaselibrary 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.InstallationPre-requisiteworking Couchbase server / clusterworking Sync-Gateway serverRequirementscouchbase==2.0.2django-extensions==1.5.5django-tastypie==0.12.2requests==2.7.0shortuuid==0.4.2couchbasepackage installation can be tricky. A recipe for Ubuntu 12:sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1204.list
wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install libcouchbase-dev libcouchbase2-libeventFor Ubuntu 14:sudo wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1404.list
wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install libcouchbase-dev libcouchbase2-libeventQuick InstallInstall package:pip install django-cbtoolsThe following configuration settings are used for the package (you can use the set below for the fast installation):COUCHBASE_BUCKET = 'default'
COUCHBASE_HOSTS = ['127.0.0.1']
COUCHBASE_PASSWORD = None
SYNC_GATEWAY_BUCKET = 'default'
SYNC_GATEWAY_URL = 'http://127.0.0.1:4984'
SYNC_GATEWAY_ADMIN_URL = 'http://127.0.0.1:4985'
SYNC_GATEWAY_USER = "demo_admin"
SYNC_GATEWAY_PASSWORD = "demo_admin_password"
SYNC_GATEWAY_GUEST_USER = "demo_guest"
SYNC_GATEWAY_GUEST_PASSWORD = "demo_guest_password"Adddjango_cbtoolstoINSTALLED_APPS:INSTALLED_APPS = (
    # ...
    'django_cbtools',
)Create foldercouchbase_viewsin the project root.TestingYou should create a testing couchbase bucket to run the package tests
(and further your apps tests). For exampledefault_test.The testing bucket must containtestin 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:{
    "adminInterface":"0.0.0.0:4985",
    "databases": {
        "default": {
            "server": "http://127.0.0.1:8091",
            "bucket": "default"
        },
        "default_test": {
            "server": "http://127.0.0.1:8091",
            "bucket": "default_test"
        }
    }
}Also you need an alternativesettings.pyto 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:COUCHBASE_BUCKETis targetted to test bucketSYNC_GATEWAY_BUCKETis targetted to test bucketCOUCHBASE_STALEis set to disable Couchbase cachingLike that, in filesettings_test.py:# ...
COUCHBASE_BUCKET = 'default_test'
COUCHBASE_STALE = False
SYNC_GATEWAY_BUCKET = 'default_test'
# ...Now run tests as usual for django:python manage.py test --settings=<your-project>.settings_test django_cbtools