Django The ‘image’ attribute has no file associated with it

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 %}
    <img src="https://stackoverflow.com/questions/15322391/{{ person.image.url }}">
{% endif %}

Leave a Comment