10
votes

Currently I'm working on a django app which runs on the top of google app engine. One of a field of model looks like,

picture = models.ImageField()

But it shows the below error while saving that particular model

  File "/django_projects/cityguide-backend/src/lib/django/db/models/fields/files.py", line 93, in save
    self.name = self.storage.save(name, content, max_length=self.field.max_length)
  File "/django_projects/cityguide-backend/src/lib/django/core/files/storage.py", line 63, in save
    name = self._save(name, content)
  File "/django_projects/cityguide-backend/src/lib/django/core/files/storage.py", line 248, in _save
    fd = os.open(full_path, flags, 0o666)
  File "/google_appengine/google/appengine/tools/devappserver2/python/stubs.py", line 73, in fake_open
    raise OSError(errno.EROFS, 'Read-only file system', filename)
OSError: [Errno 30] Read-only file system: u'/django_projects/backend/src/Screenshot_from_2014-04-18_190527.png'

After some researches I found that, GAE won't support writing operations to file system . Think I need to use GAE's blobstore or Google Cloud storage. But I don't know how to integrate these with the django's model.

1

1 Answers

5
votes

To be specific, Django doesn't support App Engine's Cloud Storage or Datastore by default and requires custom storage providers to work with them. These are the solutions which are covered by the official Google docs:

  • Django non-rel which supports App Engine Datastore. See also the related article in the Cloud Platform documentation.
  • If you prefer to use CloudSQL or an external MySQL database as a back-end, you can use the django.db.backends.mysql module as per this guide.

There are also the following unofficial projects:

If you want to implement your own storage provider using Cloud Storage you can take a look at storage.py from django-appengine-toolkit as a reference.