0

Hope you are all having a very good Friday!

I am running a django project on nginx, and my project is each time going into this url - https://sitename.com/internal-nginx-static-location_uat/project_name/static/images/success.svg I didn't configure this internal-nginx-static, and If I load the same project on another website, it works fine, is it something I can handle in code, or I have make changes in server conf.

Here is my URL.py Files

from django.conf import settings
from django.contrib import admin
from django.conf.urls.static import static
from django.urls import path, include

urlpatterns = [
    path('', include('portal.urls')),
    path('admin/', admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

and settings file

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(DATA_DIR, 'static')

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
  • there is specif nginx setup that needs to happen for django seen here https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html specifically the /media and /static routes (note that working locally from serve is different) that +static helper is only used in local development and used to contain an if (debug) case which became default https://docs.djangoproject.com/en/2.1/howto/static-files/#serving-files-uploaded-by-a-user-during-development you need to seup nginx to handle /static and /meida assets. (turn off debug) – Cameron Sep 03 '21 at 14:15
  • Thank you that worked! – Kashyap Patel Nov 10 '21 at 18:27

0 Answers0