Django The 'image' attribute has no file associated with it

后端 未结 7 956
萌比男神i
萌比男神i 2020-12-01 07:09

When a user registers for my app.I receive this error when he reaches the profile page.

The \'image\' attribute has no file associated with it.
Exception Typ         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 07:50

    bob and person are the same object,

    person = Person.objects.get(user=request.user)
    bob = Person.objects.get(user=request.user)
    

    So you can use just person for it.

    In your template, check image exist or not first,

    {% if person.image %}
        
    {% endif %}
    

提交回复
热议问题