Ich habe versucht, dies für etwa eine Woche ohne Erfolg einzurichten, also bin ich verzweifelt um etwas Hilfe hier. Ich folgte dem Tutorial auf dieser Seite: https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/, um meine Django-App einzurichten und zu versuchen, auf EB zu deployen, aber es scheitert immer dann, wenn es den Befehl collectstatic erreicht.Django EB mit S3 Speicher - Collectstatic fail
Hier ist, was ich bisher haben ..
Fehler Traceback
Traceback (most recent call last):
File "/opt/python/current/app/manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle
collected = self.collect()
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 124, in collect
handler(path, prefixed_path, storage)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 337, in copy_file
if not self.delete_file(path, prefixed_path, source_storage):
File "/opt/python/run/venv/local/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 255, in delete_file
if self.storage.exists(prefixed_path):
File "/opt/python/run/venv/local/lib/python3.4/site-packages/storages/backends/s3boto.py", line 454, in exists
return k.exists()
File "/opt/python/run/venv/local/lib/python3.4/site-packages/boto/s3/key.py", line 539, in exists
return bool(self.bucket.lookup(self.name, headers=headers))
File "/opt/python/run/venv/local/lib/python3.4/site-packages/boto/s3/bucket.py", line 143, in lookup
return self.get_key(key_name, headers=headers)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/boto/s3/bucket.py", line 193, in get_key
key, resp = self._get_key_internal(key_name, headers, query_args_l)
File "/opt/python/run/venv/local/lib/python3.4/site-packages/boto/s3/bucket.py", line 231, in _get_key_internal
response.status, response.reason, '')
boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request
settings.py
AWS_ACCESS_KEY_ID=os.environ.get('AWS_ACCESS_KEY_ID',None)
AWS_SECRET_KEY=os.environ.get('AWS_SECRET_KEY',None)
AWS_SECRET_ACCESS_KEY=os.environ.get('AWS_SECRET_KEY', None)
AWS_STORAGE_BUCKET_NAME = '<my bucket name>'
AWS_S3_HOST='s3.us-east-2.amazonaws.com'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.us-east-2.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
STATICFILES_LOCATION = 'static'
STATICFILES_STORAGE = 'custom_storages.StaticStorage'
STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, STATICFILES_LOCATION)
MEDIAFILES_LOCATION = 'media'
MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION)
DEFAULT_FILE_STORAGE = 'custom_storages.MediaStorage'
custom_storage.py
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
location = settings.STATICFILES_LOCATION
class MediaStorage(S3BotoStorage):
location = settings.MEDIAFILES_LOCATION
Ich habe versucht, einige Lösungen, einschließlich, aber nicht beschränkt auf:
- Using Django's collectstatic with boto S3 throws "Error 32: Broken Pipe" after a while
jede Hilfe sehr geschätzt wird. Vielen Dank!
im Tutorial der Suche und der Tatsache, dass Sie verwenden python 3, hast du django-storage-redux installiert und hinzugefügt? –
Nach @AlanAvalos benötigen Sie django-storage-redux in Ihrem Projekt. Meine Frage kann Ihnen helfen http://stackoverflow.com/questions/41427837/django-wont-serve-static-files-from-amazon-s3-with-custom-domain/41433454#41433454 –
Ja, ich habe Django-Speicher installiert -redux –