[英]django AttributeError: 'tuple' object has no attribute 'rsplit'
[英]AttributeError: 'tuple' object has no attribute 'rsplit' Django
我是 django 的新手,在運行命令python manage.py collectstatic
后出現此錯誤
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/management/__init__.py", line 76, in load_command_class
return module.Command()
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/contrib/staticfiles/management/commands/collectstatic.py", line 58, in __init__
self.storage.path('')
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/utils/functional.py", line 213, in inner
self._setup()
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/contrib/staticfiles/storage.py", line 311, in _setup
self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/core/files/storage.py", line 282, in get_storage_class
return import_by_path(import_path or settings.DEFAULT_FILE_STORAGE)
File "/Users/bradfordli/Development/django_tutorial/lib/python2.7/site-packages/Django-1.6.2-py2.7.egg/django/utils/module_loading.py", line 16, in import_by_path
module_path, class_name = dotted_path.rsplit('.', 1)
AttributeError: 'tuple' object has no attribute 'rsplit'
當我運行服務器時,這是runserver
您的settings.py中的一項settings.py
是一個元組,或者使用了不必要的尾部逗號,這會將其變成一個元組,並且不應該這樣。 應該是一個字符串。
我將從查看STATICFILES_STORAGE
和DEFAULT_FILE_STORAGE
我有同樣的問題。
我復制后
REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework_simplejwt.authentication.JWTAuthentication', (...) ), }
進入我的項目。 然后我在上面提到的設置中刪除了 (...),它現在可以工作了。 請小心復制代碼))
我在 Django Rest 框架中使用 djoser 進行身份驗證時出現此錯誤。 只是改變
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
(...)
),
}
到
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework_simplejwt.authentication.JWTAuthentication',
),
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.