-1

I had static files in django.

Project Structure Sample

enter image description here

I have project structure like above i want to use js and img from asset folder. How can i do this ? How i can avoid using {% static "abc.jpg" %} ?

MD. Khairul Basar
  • 4,976
  • 14
  • 41
  • 59
Chirag Jain
  • 9
  • 1
  • 6

1 Answers1

1

First you need to keep this files in static folder Keep these files out of templates like

project_main_folder/static/img/abc.jpg

The recommended way is to use static tag provided by django.

{% static  "abc.jpg" %}

Without static tag you can do this like

 <img src="host:port/static/img/abc.jpg" />

or

<img src="/static/img/abc.jpg" />

This is not recommend.

Umar Asghar
  • 3,808
  • 1
  • 36
  • 32