Posted by José Lopes.
When you upload images on a Django project it is normal to expect to have them displayed when editing the concerned record in the administration page.
This post shows what to do to display the images in the administration change page.
Just copy the file 'PATH to Django's directory'/django/contrib/admin/templates/widget/file.html to the directory templates/widget of your project.
We are using the same principle as for, per example, costumizing the admin pages. Here the template file file.html defines how the image fields are displayed in the admin.
The original file has the following lines:
{% load admin_modify i18n %}{% if bound_field.original_value %}
{% trans "Currently:" %} <a href="{{ bound_field.original_url }}" > {{ bound_field.original_value|escape }} </a><br />
{% trans "Change:" %}{% output_all bound_field.form_fields %}
{% else %} {% output_all bound_field.form_fields %} {% endif %}
We can modify it to include the images, like per example:
{% load admin_modify i18n %}{% if bound_field.original_value %}
<img src="/site_media/{{ bound_field.original_url }}">
{% trans "Change:" %}{% output_all bound_field.form_fields %}
{% else %} {% output_all bound_field.form_fields %} {% endif %}
Just a remark, the image path has site_media assuming that the image is uploaded to there. To be aware that the correct path to the image depends upon our settings.
A final remark, each time the template file is changed we must run in a shell python manage.py runserver in order to see the changes.