Hey there!
Sorry for the bother, but I'm running into some issues dealing with static files for a new site I'm building with Django. I'm new to django, but I swear I went through at least 5 hours of StackOverflow comments and other guides before hitting up this group. Anyway:[date_stuff] [error] [log_stuff]: *1 open() "/server/website/<project_name>/static/home/global.css" failed (2: No such file or directory), client: [redacted], server: [redacted], request: "GET /static/home/global.css HTTP/2.0", host: "[redacted]", referrer: "https://www.[redacted]"
Some things that I noticed:
I don't know how, but the request sent to nginx for the global.css asset is trying to get it from `/server/website/<project_name>/static/home/global.css`, instead of `/server/website/static/home/global.css`.
I'm not sure at that point whether it's an nginx problem or a django one, but for some reason the `<project_name>` is being added, and nginx is trying to fetch the static files from the wrong place.
I don't know how, but the request sent to nginx for the global.css asset is trying to get it from `/server/website/<project_
I'm not sure at that point whether it's an nginx problem or a django one, but for some reason the `<project_name>` is being added, and nginx is trying to fetch the static files from the wrong place.
# Project overview
Server/ <----- Located at the root of the machine at /server
---- Vagrantfile
---- db/
---- letsencrypt/
---- nginx/
---- uwsgi/
---- website/ <--- Project root
---- <project_name>/
---- home/ <--- home app
---- templates/
---- static/
---- admin/
---- home/
---- global.css <--- collected from the static dir in the `home` app# <project_name>/settings.py config:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__ file__)))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'home',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.static',
],
},
},
]
STATIC_URL = '/static/'
# STATIC_ROOT = os.path.join(BASE_DIR, 'static/') <------ I've tried this and just hardcoding
STATIC_ROOT = '/server/website/static/'
# Nginx server config:location /static {
alias /server/website/static; <---- I've tried this and setting `root /server/website`
Cheers and thanks for any help guys (and sorry for the bother on such a beginner question),
JasonYou received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/162af149-2e2b-42f2-a4ee-67dcb7a74da2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment