在原始随机默认头像上裁剪保存会提示如下错误:
builtins.TypeError
TypeError: join() argument must be str or bytes, not 'NoneType'
Traceback (most recent call last)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask_login\utils.py", line 261, in decorated_view
return func(*args, **kwargs)
File "D:\FlaskProjects\FlaskHTTP\myalbumy\myalbumy\decorators.py", line 21, in decorated_function
return func(*args, **kwargs)
File "D:\FlaskProjects\FlaskHTTP\myalbumy\myalbumy\blueprints\user.py", line 178, in crop_avatar
filenames = avatars.crop_avatar(current_user.avatar_raw, x, y, w, h)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\site-packages\flask_avatars\__init__.py", line 312, in crop_avatar
path = os.path.join(current_app.config['AVATARS_SAVE_PATH'], filename)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\ntpath.py", line 115, in join
genericpath._check_arg_types('join', path, *paths)
File "C:\Users\张启宏\.virtualenvs\FlaskProjects-BArbVR56\lib\genericpath.py", line 149, in _check_arg_types
Open an interactive python shell in this frame(funcname, s.__class__.__name__)) from None
原因应该是current_user.avartar_raw为None,该如何修改?