Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Python3 compatible Django storage backend for Amazon S3?

I'm building a Django app in Python 3.3.1 to be deployed on Heroku. Due to its ephemeral filesystem, Heroku can't serve the app's static files from a local filesystem, so they need to be located elsewhere, and Amazon S3 is where I'd like to put them.

I've found a number of helpful tutorials (Deploying Django on Heroku, among others), all of which make use of the django-storages app and boto to collect the static files and store them on S3. Unfortunately, work on porting boto to Python3 is still incomplete. There are other S3 storage providers that django-storages can work with (Apache Libcloud or the simple Amazon S3 Python library), but django-storages itself doesn't run on Python3, either.

I've also seen hacks that add a collectstatic call to the Heroku app's Procfile, which does put the files somewhere that they can be used by the Django app, but it slows down deployment; the files must be collected and uploaded every time the app deploys. Heroku dynos aren't well-suited to serving static files, anyhow, and I'd eventually like to store user data, as well, which will require a non-Heroku data store like S3.

Is there a Python3-compatible storage backend for Django other than those provided in django-storages? Or am I stuck with Python 2.7 for the time being?

like image 940
Lonnon Foster Avatar asked Apr 11 '13 19:04

Lonnon Foster


People also ask

How do I upload files to AWS s3 using Django REST framework?

Building a simple Django Rest API application Execute the commands below to set up the project. Add the code snippet below to urls.py file in the dropboxer project directory. Create serializers.py and urls.py files in the uploader app. In models.py file, we create a simple model that represents a single file.

How does Django storages work?

The django-storages is an open-source library to manage storage backends like Dropbox, OneDrive and Amazon S3. It's very convenient, as it plugs in the built-in Django storage backend API. In other words, it will make you life easier, as it won't drastically change how you interact with the static/media assets.


1 Answers

django-storages-redux (now just django-storages) is working for me very nicely in conjunction with boto which now has Python 3 support for its s3 functionality.

like image 143
meshy Avatar answered Nov 16 '22 03:11

meshy