欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

AttributeError: ‘NoneType‘ object has no attribute ‘name‘

程序员文章站 2024-03-25 11:28:04
...
Internal Server Error: /upload/
Traceback (most recent call last):
  File "D:\Program Files (x86)\Python38\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "D:\Program Files (x86)\Python38\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Administrator\PycharmProjects\day06\App\views.py", line 57, in handle_upload
    path = os.path.join(path, fobj.name)
AttributeError: 'NoneType' object has no attribute 'name'
[21/Oct/2020 10:31:28] "GET /upload/ HTTP/1.1" 500 63809
Not Found: /favicon.ico
[21/Oct/2020 10:31:29] "GET /favicon.ico HTTP/1.1" 404 4545


AttributeError: ‘NoneType‘ object has no attribute ‘name‘
是因为这里没写:
if request.method == ‘POST’:

相关标签: django