Облачное хранилище Django 'Ошибка типа: неверный файл: нет' на python3 manage.py collectstatic
Я установил django-cloudinary-storage для хранения моих статических и мультимедийных файлов в Cloudinary для моего проекта django. Я следовал инструкциям, приведенным здесь - https://github.com/klis87/django-cloudinary-storage
Мой settings.py выглядит следующим образом:
DEBUG = False
# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'cloudinary_storage.storage.StaticHashedCloudinaryStorage'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
#Media files (User uploaded Images, Videos)
MEDIA_URL = '/media/'
DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'
CLOUDINARY_STORAGE = {
'CLOUD_NAME': os.environ.get('CLOUDINARY_CLOUD_NAME'),
'API_KEY': os.environ.get('CLOUDINARY_API_KEY'),
'API_SECRET': os.environ.get('CLOUDINARY_API_SECRET'),
'INVALID_VIDEO_ERROR_MESSAGE': 'Please upload a valid video file.',
'EXCLUDE_DELETE_ORPHANED_MEDIA_PATHS': (),
'STATIC_IMAGES_EXTENSIONS': ['jpg', 'jpe', 'jpeg', 'jpc', 'jp2', 'j2k', 'wdp', 'jxr',
'hdp', 'png', 'gif', 'webp', 'bmp', 'tif', 'tiff', 'ico'],
'STATIC_VIDEOS_EXTENSIONS': ['mp4', 'webm', 'flv', 'mov', 'ogv' ,'3gp' ,'3g2' ,'wmv' ,
'mpeg' ,'flv' ,'mkv' ,'avi']
}
На данный момент у меня есть только один статический файл по указанному ниже пути:
BASE_DIR/static/css/fonts.css
Я пытаюсь загрузить файл в Cloudinary, выполнив collectstatic, но каждый раз выдает эту ошибку -
Traceback(most recent call last):
File "manage.py", line 15, in < module >
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute( * args, ** cmd_options)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 335, in execute
output = self.handle( * args, ** options)
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 189, in handle
collected = self.collect()
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 129, in collect
for original_path, processed_path, processed in processor:
File "/usr/local/lib/python3.5/dist-packages/cloudinary_storage/storage.py", line 315, in post_process
for response in super(HashCloudinaryMixin, self).post_process(paths, dry_run, ** options):
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/storage.py", line 405, in post_process
yield from super().post_process( * args, ** kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/storage.py", line 239, in post_process
for name, hashed_name, processed, _ in self._post_process(paths, adjustable_paths, hashed_files):
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/storage.py", line 296, in _post_process
content = pattern.sub(converter, content)
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/storage.py", line 197, in converter
force = True, hashed_files = hashed_files,
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/storage.py", line 134, in _url
hashed_name = hashed_name_func( * args)
File "/usr/local/lib/python3.5/dist-packages/django/contrib/staticfiles/storage.py", line 345, in _stored_name
cache_name = self.clean_name(self.hashed_name(name))
File "/usr/local/lib/python3.5/dist-packages/cloudinary_storage/storage.py", line 286, in hashed_name
content = open(absolute_path, 'rb')
TypeError: invalid file: None
Прежде чем выдать ошибку, он правильно собирает все статические файлы из admin-app:
Post-processed 'admin/js/vendor/select2/i18n/fr.js' as 'static/admin/js/vendor/select2/i18n/fr.b06a3340de45.js'
Post-processed 'admin/js/vendor/select2/i18n/tr.js' as 'static/admin/js/vendor/select2/i18n/tr.c1925d8817db.js'
Post-processed 'admin/js/vendor/select2/i18n/ar.js' as 'static/admin/js/vendor/select2/i18n/ar.a8bb27ec698c.js'
Post-processed 'admin/js/vendor/select2/i18n/vi.js' as 'static/admin/js/vendor/select2/i18n/vi.3520aa7bdea8.js'
Post-processed 'admin/js/vendor/select2/i18n/nb.js' as 'static/admin/js/vendor/select2/i18n/nb.137e184004aa.js'
Post-processed 'admin/js/vendor/select2/i18n/en.js' as 'static/admin/js/vendor/select2/i18n/en.05649b26c086.js'
Post-processed 'admin/js/vendor/select2/i18n/is.js' as 'static/admin/js/vendor/select2/i18n/is.808c7d47acb5.js'
Post-processed 'admin/js/vendor/select2/i18n/ko.js' as 'static/admin/js/vendor/select2/i18n/ko.74b17541834f.js'
Post-processed 'admin/js/vendor/select2/i18n/nl.js' as 'static/admin/js/vendor/select2/i18n/nl.c363ace8aa05.js'
Post-processed 'admin/js/vendor/select2/i18n/pt.js' as 'static/admin/js/vendor/select2/i18n/pt.5d6ccc53b347.js'
Post-processed 'admin/js/vendor/select2/i18n/sr-Cyrl.js' as 'static/admin/js/vendor/select2/i18n/sr-Cyrl.2f3047aad49e.js'
Post-processed 'admin/js/vendor/select2/i18n/hr.js' as 'static/admin/js/vendor/select2/i18n/hr.e1d2c70b4df5.js'
Post-processed 'admin/js/vendor/select2/i18n/az.js' as 'static/admin/js/vendor/select2/i18n/az.498dc667b34e.js'
Post-processed 'admin/js/vendor/select2/i18n/lv.js' as 'static/admin/js/vendor/select2/i18n/lv.07fe2a580d17.js'
Post-processed 'admin/js/vendor/select2/i18n/zh-CN.js' as 'static/admin/js/vendor/select2/i18n/zh-CN.419002d3c6c1.js'
Post-processed 'admin/js/vendor/select2/i18n/pl.js' as 'static/admin/js/vendor/select2/i18n/pl.76465b54a6b0.js'
Post-processed 'admin/js/vendor/select2/i18n/bg.js' as 'static/admin/js/vendor/select2/i18n/bg.89cba4df3c86.js'
Post-processed 'admin/js/vendor/select2/i18n/km.js' as 'static/admin/js/vendor/select2/i18n/km.6074a9c5575c.js'
Post-processed 'admin/js/vendor/select2/i18n/ca.js' as 'static/admin/js/vendor/select2/i18n/ca.2eaad4eb1950.js'
...
...
...
Насколько я понимаю, похоже, это как-то связано с тем, что мой файл fonts.css не имеет хешированного имени. Но с другой стороны, если это так, не должны ли настройки
STATICFILES_STORAGE = 'cloudinary_storage.storage.StaticHashedCloudinaryStorage'
позаботься об этом. Если нет, то как я могу загрузить свои статические файлы в Cloudinary, поддерживая также хеширование?
Пожалуйста помоги. Спасибо!