I am trying to access these files used from the django-import-export-celery
module:
I am able to see my view on local:
But its not showing on my production server:
This is my urlpattern
:
urlpatterns = static(
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
) [
# favicon
path('favicon.ico', RedirectView.as_view(url=staticfiles_storage.url('img/Dalmore-Group-16-16.png'))),
# debug
path('__debug__/', include(debug_toolbar.urls)),
url(r'^', admin.site.urls),
]
And my settings.py
has:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
UPDATE:
I am receiving this error on my logs:
tail /var/log/gunicorn.err.log
WARNING:django.request:Not Found: /media/django-import-export-celery-import-change-summaries/new1_1_1hRlmBz_ubIptVv_St8xqbE_1_z2_PGH9e4O.html
Even though it's present:
ls -A media/django-import-export-celery-import-change-summaries/
new1_1_1hRlmBz_ubIptVv_St8xqbE_1_z2_PGH9e4O.html
CodePudding user response:
I added this:
location /media/ {
root /home/ubuntu/dalmoreportal;
}
in /etc/nginx/sites-available/django.conf