Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django template: static files in app directory

Tags:

python

django

In Django settings.py file we have

STATIC_URL = '/static/'

And in each app directory I have static folder for css, js files.

For example:

├── myapp
│   ├── migrations
│   ├── __pycache__
│   ├── static
│   └── templates

When I use {% static "......." %} in *.html file

For example

  <link rel="stylesheet" href="{% static "style/fesahat.css" %}" />
  <link rel="stylesheet" href="{% static "style/loginStyle.css" %}" />

In output render django creates URL like this:

mysite.com/static/style/fesahat.css
mysite.com/static/style/loginStyle.css

I want to create the URL like this:

mysite.com/myapp/templates/static/style/fesahat.css
mysite.com/myapp/templates/static/style/loginStyle.css
like image 703
javad75 Avatar asked Jan 18 '26 12:01

javad75


1 Answers

No you don't. Static files are not templates; don't put them there.

like image 61
Daniel Roseman Avatar answered Jan 21 '26 02:01

Daniel Roseman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!