Django – Display ImageField
An ImageField contains a url attribute, which you can use in your templates to render the proper HTML. {% block content %} <img src=”https://stackoverflow.com/questions/17846290/{{ carx.photo.url }}”> {% endblock %}
An ImageField contains a url attribute, which you can use in your templates to render the proper HTML. {% block content %} <img src=”https://stackoverflow.com/questions/17846290/{{ carx.photo.url }}”> {% endblock %}
You can receive the pre_delete or post_delete signal (see @toto_tico’s comment below) and call the delete() method on the FileField object, thus (in models.py): class MyModel(models.Model): file = models.FileField() … # Receive the pre_delete signal and delete the file associated with the model instance. from django.db.models.signals import pre_delete from django.dispatch.dispatcher import receiver @receiver(pre_delete, sender=MyModel) def … Read more