J'utilise django-s3-storage==0.11.2 et boto3==1.4.4. Ceux-ci sont dans le settings.py:django s3 storages ne reconnaît pas le nom du compartiment
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, 'static_cdn')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media_cdn')
AWS_S3_BUCKET_NAME = "my-bucket-name"
AWS_ACCESS_KEY_ID = 'test_id_x'
AWS_SECRET_ACCESS_KEY = 'test_id_x+test_id_x'
DEFAULT_FILE_STORAGE = "django_s3_storage.storage.S3Storage"
STATICFILES_STORAGE = "django_s3_storage.storage.StaticS3Storage"
AWS_S3_ADDRESSING_STYLE = "auto"
AWS_S3_BUCKET_AUTH_STATIC = False
AWS_S3_MAX_AGE_SECONDS_STATIC = 60 * 60 * 24 * 365 # 1 year.
AWS_S3_BUCKET_AUTH = False
AWS_S3_MAX_AGE_SECONDS = 60 * 60 * 24 * 365 # 1 year.
J'ai aussi couru ces commandes:
manage.py s3_sync_meta django.core.files.storage.default_storage
Mais quand je lance collectstatic
ou cette commande
manage.py s3_sync_meta django.contrib.staticfiles.storage.staticfiles_storage
-je obtenir cette erreur:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Invalid bucket name "": Bucket name must match the regex "^[a-zA-Z0-9.\-_]{1,255}$"
I avez déjà créé le compartiment et le nom du compartiment est correct. Parce que cela fonctionne et ne donne aucune erreur:
s3.meta.client.head_bucket(Bucket='my-bucket-name')
Je ne sais pas ce qui me manque ici? Pourriez-vous m'aider s'il vous plait.
Dans la section INSTALLED_APPS de settings.py avez-vous ajouté __django_s3_storage__? – tom
@tom Oui, je l'ai ajouté aux applications installées dans les paramètres. – Kakar