I have results to get the image url from a django form.
Model:
class Sponsor(models.Model): image = ProcessedImageField(upload_to='sponsors/', processors=[SmartResize(300, 120, upscale=False)], format='JPEG', options={'quality': 100}, null=True)
the form:
class SponsorForm(forms.ModelForm): class Meta: model = Sponsor fields = ('image',)
When I create it using:
{{ sponsorform.image }}
He prints:
Currently: <a href="/media/sponsors/random1.jpg">sponsors/random1.jpg</a> <br>Change: <input id="id_sponsor-image" name="sponsor-image" type="file">
So my question is: how to get this url in templates? I tried:
{{ sponsorform.image.url }} {{ sponsorform.image.path }} {{ sponsorform.image.href }}
But nothing works, no suggestions?
source share