TypeError应用Django项目

赖安市
赖安市 成员文章数 :3
编辑2022 开发者APIs

所以我有Django项目使用django-cloudinary-storage.可当我开机时调试错误表示 : TypeError:期望字符串、字节或os.Pathel对象,而非NoneType


我不明白我做错什么看一看回溯 看出什么问题谢谢

需要更多信息请通知


回溯(最近最后调用):文件 "/opt/homebre/Celler/[email protected]3.9.10/Frameworks/Python.frame/Version/9/lib/pyth3.9/py[email protected]/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run     self._target(*self._args, **self._kwargs)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper     fn(*args, **kwargs)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 157, in inner_run     handler = self.get_handler(*args, **options)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 31, in get_handler     handler = super().get_handler(*args, **options)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 78, in get_handler     return get_internal_wsgi_application()   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/core/servers/basehttp.py", line 47, in get_internal_wsgi_application     return import_string(app_path)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/utils/module_loading.py", line 30, in import_string     return cached_import(module_path, class_name)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/utils/module_loading.py", line 15, in cached_import     import_module(module_path)   File "/opt/homebrew/Cellar/[email protected]3.9.10/Frameworks/Python.frame/Version/3.9/lib/pyth3.9/importlib/__iint-py.
                    
                     第1030行输入文件
                     
                      第1007行.find_and_loadfile
                      
                       986行查找并装入非锁文件
                       
                        第680行 上载非锁文件
                        
                         850行执行模块文件
                         
                          228行用_frames-removefile/Users/ryanoh/Projects/crystalize/crystalize/wsgi/wsgi
                          
                           application = get_wsgi_application()   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application     return WSGIHandler()   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 126, in __init__     self.load_middleware()   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/core/handlers/base.py", line 61, in load_middleware     mw_instance = middleware(adapted_handler)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/middleware.py", line 51, in __init__     self.add_files(self.static_root, prefix=self.static_prefix)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/base.py", line 113, in add_files     self.update_files_dictionary(root, prefix)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/base.py", line 125, in update_files_dictionary     self.add_file_to_dictionary(url, path, stat_cache=stat_cache)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/base.py", line 136, in add_file_to_dictionary     static_file = self.get_static_file(path, url, stat_cache=stat_cache)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/base.py", line 210, in get_static_file     self.add_cache_headers(headers, path, url)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/base.py", line 231, in add_cache_headers     if self.immutable_file_test(path, url):   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/middleware.py", line 146, in immutable_file_test     static_url = self.get_static_url(name_without_hash)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/whitenoise/middleware.py", line 169, in get_static_url     return decode_if_byte_string(staticfiles_storage.url(name))   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 166, in url     return self._url(self.stored_name, name, force)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 145, in _url     hashed_name = hashed_name_func(*args)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/django/contrib/staticfiles/storage.py", line 394, in stored_name     self.hashed_name(name, content=None, filename=intermediate_name)   File "/Users/ryanoh/Projects/crysenv/lib/python3.9/site-packages/cloudinary_storage/storage.py", line 286, in hashed_name     content = open(absolute_path, 'rb') TypeError: expected str, bytes or os.PathLike object, not NoneType
                          
                         
                        
                       
                      
                     
                    
标记 :

答案解析

  • 兰森市
    兰森市 云化员工文章数 :16

    赖安

    试图存取文件但存取文件时通常出错提供值文件名需要弄清楚哪里值取自并校正赋值例例开法值可查文件存取方法/函数并通知我们

Baidu
map