please use either motion.attachments.exists or even better:

```python
{% with attachments = motion.attachments.all %}
{%if attachments %}
...
{% endif %}
{% endwith %}
```