Home > OS >  Django - resource was not found on this server on production
Django - resource was not found on this server on production

Time:12-17

I am trying to access these files used from the django-import-export-celery module: enter image description here

I am able to see my view on local:

enter image description here

But its not showing on my production server:

enter image description here

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

enter image description here

CodePudding user response:

I added this:

location /media/ { 
    root /home/ubuntu/dalmoreportal;
} 

in /etc/nginx/sites-available/django.conf

  • Related