Coder Social home page Coder Social logo

Comments (8)

jdewanwala avatar jdewanwala commented on July 22, 2024 2

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:

1. Folder Structure
screen shot 2017-12-10 at 1 53 18 pm

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.

AndreasBackx avatar AndreasBackx commented on July 22, 2024 1

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.

jrief avatar jrief commented on July 22, 2024 1

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.

AndreasBackx avatar AndreasBackx commented on July 22, 2024

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.

jdewanwala avatar jdewanwala commented on July 22, 2024

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:
screen shot 2017-12-09 at 4 15 43 pm

print(BASE_DIR) outputs:
../../django/sassy

from django-sass-processor.

jdewanwala avatar jdewanwala commented on July 22, 2024

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:
screen shot 2017-12-09 at 6 03 21 pm

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.

jrief avatar jrief commented on July 22, 2024

You must add sassy to your INSTALLED_APPS.

from django-sass-processor.

jdewanwala avatar jdewanwala commented on July 22, 2024

Hello, thanks for your response!

1. I did, but it presents same error, presented here in full:
screen shot 2017-12-09 at 11 52 02 pm

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.