Hi all,
I have a django application (containerised), which works and serves static files.
I want to serve this application under a nginx proxy.
But suddenly, the static files are not found by django.
In urls.txt, I have the following code:
urlpatterns = [
path('admin/', admin.site.urls),
path('scrape/', include('crawlerScrapy.urls')),
path('api/', include('api.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
print('STATIC_URL:', settings.STATIC_URL)
print('STATIC_ROOT:', settings.STATIC_ROOT)
print('URL Patterns:', urlpatterns)
import os
print(os.listdir(settings.STATIC_ROOT + 'rest_framework/js'))
When the code runs, I get the following:
STATIC_URL: /disinformation_data_server/static/
STATIC_ROOT: /app/static/
URL Patterns: [<URLResolver <URLPattern list> (admin:admin) 'admin/'>, <URLResolver <module 'crawlerScrapy.urls' from '/app/crawlerScrapy/urls.py'> (None:None) 'scrape/'>, <URLResolver <module 'api.urls' from '/app/api/urls.py'> (None:None) 'api/'>, <URLPattern '^disinformation_data_server/static/(?P<path>.*)$'>]
['load-ajax-form.js', 'jquery-3.7.1.min.js', 'bootstrap.min.js', 'prettify-min.js', 'coreapi-0.1.1.js', 'csrf.js', 'ajax-form.js', 'default.js']
So, everything seems fine from inside django. But when the static files are requested, I see in the logs:
Not Found: /disinformation_data_server/static/rest_framework/js/jquery-3.7.1.min.js
Not Found: /disinformation_data_server/static/rest_framework/js/ajax-form.js
Not Found: /disinformation_data_server/static/rest_framework/js/csrf.js
Since the files exist in the static folder, why I am getting that they are not found?