Comments (8)
That's great! It works! Thank you, both Jacob and Andreas! Closing the issue.
For the benefit of others, here are the final folder structure and settings:
2. Settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'scss'),
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
]
SASS_PROCESSOR_ROOT = os.path.join(BASE_DIR,"temp_files")
Rest of the settings are same as above.
from django-sass-processor.
Personally I wouldn't recommend using the static folder as your SCSS folder as it will be the place where compiled files and more end up.
After having looked a bit deeper at your configuration now that I'm on my PC, I can see that you probably don't have the scss folder setup in STATICFILES_DIRS
. Set it up like this:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'scss'),
]
The finders in STATICFILES_FINDERS
are setup to use STATICFILES_DIRS
but you don't seem to have that setup so it does not know where to look. This setup tells it that it can look for SCSS files in sassy/scss
.
And you could remove the following configuration from your settings as you've set these to the default values:
SASS_PROCESSOR_ROOT = STATIC_ROOT
SASS_PRECISION = 8
SASS_PROCESSOR_ROOT
is simply the location of the compiled SCSS file and not the place it'll look for SCSS files.
from django-sass-processor.
If you don't use STATIC_ROOT
, then you must set SASS_PROCESSOR_ROOT
.
Point it onto a directory where you keep temporary files. Sass-Processor writes the compiled CSS into that directory. From there, Django delivers that CSS file.
from django-sass-processor.
Please verify that BASE_DIR
actually points to the directory sassy
and not its parent.
Also please use proper GitHub flavoured Markdown, I've fixed it for now.
from django-sass-processor.
Thanks for the quick response Andreas. This is what the BASE_DIR refers to:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
where file is settings.py with 'standard folder' structure:
print(BASE_DIR)
outputs:
../../django/sassy
from django-sass-processor.
Hi Andreas,
So I made the changes you recommended and now get the following error:
TypeError at /
stat: path should be string, bytes, os.PathLike or integer, not NoneType
1. This is the change I made to the settings.py file:
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'scss'),
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
]
I also removed:
# SASS_PROCESSOR_ROOT = STATIC_ROOT
# SASS_PRECISION = 8
2. I moved the scss files into their own folder under the BASE_DIR
folder:
3. I am still referencing the scss in the .html file as:
<link href="{% sass_src 'main.scss' %}" rel="stylesheet" type="text/css" />
from django-sass-processor.
You must add sassy
to your INSTALLED_APPS
.
from django-sass-processor.
Hello, thanks for your response!
1. I did, but it presents same error, presented here in full:
2. Here's the whole settings.py file:
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '................'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'debug_toolbar',
'sass_processor',
'sassy',
'appone',
]
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',
'debug_toolbar.middleware.DebugToolbarMiddleware',
]
ROOT_URLCONF = 'sassy.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,"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 = 'sassy.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
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',
},
]
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'scss'),
]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'sass_processor.finders.CssFinder',
]
# STATIC_ROOT = os.path.join(BASE_DIR,"static")
# SASS_PROCESSOR_ROOT = STATIC_ROOT
# os.path.join(STATIC_ROOT,"scss")
# SASS_PRECISION = 8
# SASS_PROCESSOR_INCLUDE_DIRS = [os.path.join(STATIC_ROOT,"scss"),]
from django-sass-processor.
Related Issues (20)
- Auto-compile stops for unknown reason HOT 2
- FILE_CHARSET is removed in Django 3.1 HOT 3
- LibSass is deprecated HOT 3
- Remove note about Django 3.0 compatibility from the readme HOT 1
- Q: Compile to media storage instead of static? HOT 11
- sass_inline HOT 7
- Invalid setting 'base_url' for S3StaticStorage (from django-storages) HOT 4
- import statement in SCSS file not working with v1.0.1 HOT 1
- Compilescss failed with a lot of "non sense" errors HOT 8
- CSS not updating when DEBUG=True until I erase existing css files in Docker container HOT 1
- sequence item 1: expected str instance, WindowsPath found HOT 4
- Regression: Use of custom storages broken HOT 11
- Why does compilescss create two files HOT 1
- TypeError when using Google backend from django-storages HOT 1
- Web Page Rendering After Installation & Installation is Messed Up HOT 2
- Import-only files are not monitored for changes HOT 7
- Deprecation of STATICFILES_STORAGE in django 4.2 HOT 1
- Third party documentation no longer available HOT 7
- Error sometimes occurs when trying to compile scss
- Broken in Django 5.1 alpha due to get_storage_class HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-sass-processor.