Reputation: 1716
I trying to make or condition in django template and getting this error:
Could not parse the remainder: ' || 'default_avatar.png'' from 'userprofile.avatar || 'default_avatar.png''
code
src="/media/{{userprofile.avatar || 'default_avatar.png'}}"
Upvotes: 0
Views: 434
Reputation: 600041
||
is not valid syntax either in Python or in the Django template language.
If you want to set a default for when your object is empty, use the template filter designed for that: default
.
{{ userprofile.avatar|default:'default_avatar.png' }}
Upvotes: 3