I am trying to upload MEDIA_FILES on Amazon's S3 service. I would like to upload them at root of bucket first and then maybe create sub-folders before saving file. My test model is simple
from django.db import models
# Create your models here.
class TestModel(models.Model):
name = models.CharField(max_length=10)
logo = models.ImageField(upload_to='pictures/')
class Meta:
verbose_name = ('TestModel')
verbose_name_plural = ('TestModels')
def __unicode__(self):
pass
I have a sub-folder named pictures already created.
settigns.py
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AWS_ACCESS_KEY_ID = 'id'
AWS_SECRET_ACCESS_KEY = 'secret_key'
AWS_STORAGE_BUCKET_NAME = 'mybucket'
from S3 import CallingFormat
AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN
But when I try to add a TestModel from the admin panel I get the following error
Request URL: http://127.0.0.1:8000/admin/testmodel/testmodel/add/
Django Version: 1.6.4
Exception Type: TypeError
Exception Value:
'NoneType' object has no attribute '__getitem__'
Does s3 and django-storages work just like before? What is the value of MEDIA_URL to set when using s3? What is the value of MEDIA_ROOT to set when using S3 and django-storages?
Can I use this way to upload a file to an S3 Service? It's my first time I use a cloud storage so I am a bit confused.