Reputation: 46979
In my settings file i have the following
STATIC_URL = '/static/'
my app name is reg_service
So my directory structure is like reg_service/reg_service/settings.py
And i have the static directory in reg_service/static/js
reg_service/manage.py
reg_service/reg_service
reg_service/templates
But in my template if i include the following script the result is "GET /static/js/jquery.min.js HTTP/1.1" 404 1652
whats is wrong here
<script src="{{ STATIC_URL }}js/jquery.min.js"></script>
Upvotes: 1
Views: 879
Reputation: 1522
The idea of django is that you should serve your static files directly through your web server.
For development purposes you can 'trick' django to serve the static files themself:
urls.py:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Django will find your static files, and serve them under the url defined under STATIC_URL.
That's not very performant nor secure, but works ok for development. For production you should configure your web server (Apache, Nginx, whatever) to serve the files directly under the url defined in STATIC_URL.
For more information see: https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-during-development
Upvotes: 1