location settings for Django Uwsgi Nginx Configuration for production

sandyman nginx-forum at forum.nginx.org
Fri Sep 15 12:29:20 UTC 2017


Django settings

STATICFILES_DIRS = [STATIC_DIR, ]  
STATIC_DIR = os.path.join(BASE_DIR, 'static')  
STATIC_ROOT = '/home/sandyman/production/django_project/assets/'  
STATIC_URL = '/assets/'  

local machine  example file  

/home/sandyman/development/django_project/css/bootstrap.min.css
Template

{% load staticfiles %}
href="{% static "css/bootstrap.min.css" %}"
Production environment

ran python manage.py collectstatic 

this succesfully  created all files in sub directories of  

**/home/sandyman/production/django_project/assets/**

e.g. /home/sandyman/production/django_project/assets/css/bootstrap.min.css


** NGING configuration


**server {
   server_name sandyman.xyz www.sandyman.xyz ;
   location /static {
      alias   /home/sandyman/production/django_project/assets/;  
    }
}**
** GET Request **

Request URL:http://www.sandyman.xyz/static/css/bootstrap.min.css  
Request Method:GET  
**Status Code:404 NOT FOUND**  

file bootstrap is located in 

/home/sandyman/production/django_project/assets/css/bootstrap.min.css
Please assist me .. Ive tried many iterations of values for nginx location
but no success

django

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,276402,276402#msg-276402



More information about the nginx mailing list