My CloudVPS

Article overview

/ Django - S3 Emulation

The below instructions assume that a CloudVPS Object Store is available and that a container has been created in the account. We also asume that a S3-token has been generated in the CloudVPS Interface.

In order to integrate the CloudVPS Object Store in an existing Django web application, the following packages are required:

  • boto
  • python-dateutil (noodzakelijk voor collectstatic)
  • django-storages

The first two can be installed from PyPl's repositories, but this is not recommended for django-storages. In the version on PyPl the possibility to configure a custom host is not yet possible. Use Bitbucket to install the latest version:

pip install -e hg+

And add 'storages' to the INSTALLED_APPS tuple in the Django settings.

A large advantage of the CloudVPS Object Store is that it is largely S3 compatible. That is why the built in S3 libraries of boto and django-storages can be used and why it is easy to connect existing apps to the object store. Open the (or similar) and add the configuration below:

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = '[objectstore_access_token_here]'
AWS_SECRET_ACCESS_KEY = '[objectstore_s3_secret_here]'
AWS_STORAGE_BUCKET_NAME = '[objectstore_containername_here]'
AWS_S3_HOST = '[objectstore_tenant_id_here]'

All variables between brackets can be found in the CloudVPS Interface under object store > S3 API Tokens.

That's it! Your Django app now works with the CloudVPS Object Store!

In case you want to use the Swift backend for new Django apps: this has not yet been incorporated in django-storages. There is a fork of this package available that does support the Swift API however.

Share this article