S
S
Sergey Nizhny Novgorod2016-06-01 03:02:36
Django
Sergey Nizhny Novgorod, 2016-06-01 03:02:36

Why is Django swearing at the {{ url }} field?

Hello.
Now I am inserting the following template into the template:

<img class="" src="{{ courseitem.author_image.url }}"/>

If I didn't upload this file, I get an error: The 'author_image' attribute has no file associated with it. and screen of death.
Model goes:
author_image = models.ImageField(upload_to='', blank=True, null=True, help_text="Размер изображения 100 * 100", verbose_name="Фотография автора")

Questions:
1) Why does this template require the file to be required?
2) How to make the template not crash the page if there is no file?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question