Zorgan
Zorgan

Reputation: 9123

Use raw URL or static URL for images?

Is there any difference when using:

<img src="{% static 'images/someimage.png' %}"

and

<img src="https://s3.us-east-2.amazonaws.com/my-bucket/static/images/someimage.png"

Upvotes: 2

Views: 1193

Answers (2)

E.J. Brennan
E.J. Brennan

Reputation: 46859

The big difference is that in the first method, if you wanted to someday change the location of your static files, i.e. to another directory or even a CDN, you would only need to update the 'static' location in your settings file.

In the second method you would need to do a global search and replace to update the URLs, so some would argue that the first method is preferable.

Other than that, when the site is running, it won't make any difference as far as the user is concerned.

Upvotes: 4

Astik Anand
Astik Anand

Reputation: 13047

There is no difference as such for the image display.

Only thing is in one you are using relative path and other you are hardcoding image url.

Recommended: Relative path should be used.

Upvotes: 1

Related Questions