I have an app I am developing using:
- Django 1.5
- Google App Engine
- Google Cloud SQL
- Python 2.7.5
As using Cloud SQL I am using the pure Django not the no-rel version making full use of the Django ORM.
In the admin part of the app I want to have a form to upload a csv file using GAE Blobstore API.
What I want to achieve is the uploading of the file to the Blobstore and the Blob Key referencing this uploaded file to be saved in my model.
How would I go about doing this?
Thanks for your help.
If you're not uploading the file as part of a Django form, you can manually handle the uplaod as per BlobStore instructions, then fetch the BlobKey, and save it as a string in your Django model. That's probably the most straighforward way to go.
https://developers.google.com/appengine/docs/python/blobstore/
Another option is to take the storage component in djangoappengine (designed for Django-nonrel), and adapt it for use with normal Django. I don't think there's any reason why this shouldn't work (after you put some effort into adapting it)
https://github.com/django-nonrel/djangoappengine/blob/master/djangoappengine/storage.py