当用户注册我的app.I当他到达个人资料页面时收到此错误.
The 'image' attribute has no file associated with it.
Exception Type: ValueError
Error during template rendering
In template C:\o\mysite\pet\templates\profile.html, error at line 6
1 <h4>My Profile</h4>
2
3 {% if person %}
4 <ul>
5 <li>Name: {{ person.name }}</li>
6 <br><img src="{{ person.image.url }}">
Traceback Switch back to interactive view
File "C:\o\mysite\pet\views.py" in Profile
71. return render(request,'profile.html',{'board':board ,'person':person})
Run Code Online (Sandbox Code Playgroud)
我认为这个错误的发生是因为我的模板需要一个图像并且看到他刚刚注册了他无法添加图像,除非他进入编辑页面并添加页面然后他可以访问个人资料页面.
我的个人资料
<h4>My Profile</h4>
{% if person %}
<ul>
<li>Name: {{ person.name }}</li>
<br><img src="{{ person.image.url }}">
</ul>
{% endif %} …Run Code Online (Sandbox Code Playgroud) django ×1