Search code examples
pythondjangodjango-crispy-forms

Display currently set image in Django ImageField instead of URL


I have a Django ModelForm with an ImageField. When the user edits the model the Image Field displays:

enter image description here

Is there a way to use the URL presented beside "Currently" to display/render the set image instead of the actual URL.


Solution

  • So to get the image I actually just used an image tag in the template, however instead of using {{ form.image.url }} you can use {{ form.image.value}} and use an if statement to display some default image if it is not set.