无法显示Django后端的图像
我是从Django发送我的照片,这是我的JWT Access_Token有效载荷的一部分,目的是检索渲染,甚至在我的React应用程序中更新该图像。现在,我专注于获取图像以显示我的自定义用户模型。这是我解码时的有效负载的样子:
{
"token_type": "access",
"exp": ***,
"iat": ***,
"jti": "***",
"user_id": 1,
"username": "test",
"first_name": "",
"last_name": "",
"country": "",
"city": "",
"bio": "",
"photo": "\"profile/2022/03/27/testuserpic.png\""
}
我尝试使用此代码访问图像
let { user,logOutUser } = useContext(AuthContext)
<img
alt="..."
className="avatar border-gray"
src={`http://127.0.0.1:8000/media/${user.photo}`}
/>
,但要获得错误:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I am sending my photo from django as part of my JWT access_token payload with the intention to retrieve render and even update that image in my React app. Right now I'm focused on getting the image to show my custom user model. This is what my payload looks like when I decode it:
{
"token_type": "access",
"exp": ***,
"iat": ***,
"jti": "***",
"user_id": 1,
"username": "test",
"first_name": "",
"last_name": "",
"country": "",
"city": "",
"bio": "",
"photo": "\"profile/2022/03/27/testuserpic.png\""
}
I have tried to access the image using this code
let { user,logOutUser } = useContext(AuthContext)
<img
alt="..."
className="avatar border-gray"
src={`http://127.0.0.1:8000/media/${user.photo}`}
/>
but getting the error:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论