0

In a class named Listing in models.py, I've mentioned

img = models.ImageField(upload_to="uploads")

The uploaded images are uploaded in directory called uploads.

and in listing.html i've mentioned:

<img src="{{ listing.img }}">

And when a user visits /listing/<int:n> in the URL the listing image is not loaded unless i changed the path to:

<img src="/{{ listing.img }}">

Is there any solution to not use the absolute path (mentioning the / before listing.img) ?

0

You must log in to answer this question.

Browse other questions tagged .