Uploading files to Google Cloud Storage with Django

500 words by masci

Intro

On of the features of Django Appengine Toolkit is simplifying
the work needed to configure Google Cloud Storage as a static files storage for Django applications running on
Google App Engine. Infact all you have to do is writing something like this in your settings.py module:

A complete example

This repo contains a minimalistic Django project
implementing a file storage application that lets users upload, listing, retrieve and delete files. The project has just
one app implementing all the logic, defining the model and exposing the views. For detailed instructions on how to
setup a Django project on App Engine with django-appengine-toolkit please check out
this blog post.
Now let’s take a look at the code.

Since we need to show the list of files and the form to upload them on the same page, we cannot use a CreateView as is,
what we need is a CreateView and ListView hybrid instead, thus the hack of overriding get_context_data: we inject the queryset
in the context so the template can render properly.