The last lines of the trace:
File "/usr/local/lib64/python3.4/site-packages/django/core/files/storage.py", line 328, in get_storage_class
return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
File "/usr/local/lib64/python3.4/site-packages/django/utils/module_loading.py", line 15, in import_string
module_path, class_name = dotted_path.rsplit('.', 1)
AttributeError: type object 'S3StaticStorage' has no attribute 'rsplit'
S3StaticStorage
:
class S3StaticStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['bucket'] = getattr(settings, 'AWS_BUCKET_STATIC')
super(S3StaticStorage, self).__init__(*args, **kwargs)
I have a file called prod.py
which imports common.py
, and this is configured accordingly as the settings source in wsgi.py
and manage.py
. A line in prod.py
sets the bucket name:
AWS_BUCKET_STATIC = 'myproject-static'
This was not a problem without the override, when I was putting everything in one bucket. Do I need to import rsplit
when using this class or something? It looks like it should be in-built to Python so wouldn't need an import. If I understood it correctly, getattr(settings, 'AWS_BUCKET_STATIC')
would get the variable from whatever settings files Django finds, so that shouldn't be a problem either.
Full trace:
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib64/python3.4/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/usr/local/lib64/python3.4/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib64/python3.4/site-packages/django/core/management/__init__.py", line 195, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib64/python3.4/site-packages/django/core/management/__init__.py", line 40, in load_command_class
return module.Command()
File "/usr/local/lib64/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 32, in __init__
self.storage.path('')
File "/usr/local/lib64/python3.4/site-packages/django/utils/functional.py", line 204, in inner
self._setup()
File "/usr/local/lib64/python3.4/site-packages/django/contrib/staticfiles/storage.py", line 394, in _setup
self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
File "/usr/local/lib64/python3.4/site-packages/django/core/files/storage.py", line 328, in get_storage_class
return import_string(import_path or settings.DEFAULT_FILE_STORAGE)
File "/usr/local/lib64/python3.4/site-packages/django/utils/module_loading.py", line 15, in import_string
module_path, class_name = dotted_path.rsplit('.', 1)
AttributeError: type object 'S3StaticStorage' has no attribute 'rsplit'
看起来 STATICFILES_STORAGE
期望一个表示模块路径的字符串:
STATICFILES_STORAGE='path.to.your.S3StaticStorage'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.