My css is failing. no css commands initialize in my templates page.
django shows no errors in it but in the apache logs I see that the
stlye.css cannot be found, even with a static path.
[wsgi:error] [pid 25372] [remote 73.135.97.117:47050] Not Found:
/home/robin/www/trader/templates/trader/style.css
but the file is very much there. I tried permission 644 and 777 to the
style.css file
root@localhost:/home/robin/www/trader# ls -l
/home/robin/www/trader/templates/trader
total 12
-rw-r--r-- 1 www-data www-data 2905 May 13 14:26 index.html
-rwxrwxrwx 1 www-data www-data 155 May 13 12:46 style.css
My apache directive looks normal
<VirtualHost *:80>
ServerName coinz.com
ServerAdmin [email protected]
DocumentRoot /home/robin/www/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
WSGIDaemonProcess trader
python-path=/home/robin/www/trader/:/usr/lib/python3/dist-packages/
WSGIProcessGroup trader
WSGIScriptAlias / /home/robin/www/trader/trader/wsgi.py
<Directory /home/robin/www/trader/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
settings.py
root@localhost:/home/robin/www/trader# cat trader/settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = 'xxx'
DEBUG = True
ALLOWED_HOSTS = ['coinz.com']
# Application definition
INSTALLED_APPS = [
'trader',
'buy',
'sell',
'manager',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'trader.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/home/robin/www/trader/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',
],
},
},
]
WSGI_APPLICATION = 'trader.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'xxx',
'USER': 'xxx',
'PASSWORD': 'xxx',
'HOST': '127.0.0.1',
'PORT': '',
}
}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME':
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME':
'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
How do I get django to find my style.css?
UPDATE:
html
<head>
{% load static %}
<link rel="stylesheet" type="text/css" href={% static "style.css" %}>
</head>
and added to settings.py
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
'/home/robin/www/trader/templates/trader/',
]
adding urls.py
root@localhost:/home/robin/www/trader# cat trader/urls.py
from django.contrib import admin
from django.urls import path
from django.conf.urls import url, include
from . import views
from django.conf import settings
from django.conf.urls.static import static
app_name = 'trader'
urlpatterns = [
path('', views.index, name='index'),
path('admin/', admin.site.urls),
url(r'^buy/', include('buy.urls')),
]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
also tried:
root@localhost:/home/robin/www/trader# python3 manage.py findstatic
templates/trader/style.css
No matching file found for 'templates/trader/style.css'.
root@localhost:/home/robin/www/trader# ls -l templates/trader/style.css
-rw-r----- 1 www-data www-data 155 May 13 12:46
templates/trader/style.css
I also tried adding
ServerAlias /trader /home/robin/www/trader
to apache conf, and a few variations of.
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.