Coder Social home page Coder Social logo

django-sass-processor's Introduction

django-sass-processor

Annoyed having to run a Compass, Grunt or Gulp daemon while developing Django projects?

Well, then this app is for you! Compile SASS/SCSS files on the fly without having to manage third party services nor special IDE plugins.

Build Status PyPI PyPI version PyPI Downloads Twitter Follow

Other good reasons for using this library

  • Refer SASS/SCSS files directly from your sources, instead of referring a compiled CSS file, having to rely on another utility which creates them from SASS/SCSS files, hidden in your source tree.
  • Use Django's settings.py for the configuration of paths, box sizes etc., instead of having another SCSS specific file (typically _variables.scss), to hold these.
  • Extend your SASS functions by calling Python functions directly out of your Django project.
  • View SCSS errors directly in the debug console of your Django's development server.

django-sass-processor converts *.scss or *.sass files into *.css while rendering templates. For performance reasons this is done only once, since the preprocessor keeps track on the timestamps and only recompiles, if any of the imported SASS/SCSS files is younger than the corresponding generated CSS file.

Introduction

This Django app provides a templatetag {% sass_src 'path/to/file.scss' %}, which can be used instead of the built-in templatetag static. This templatetag also works inside Jinja2 templates.

If SASS/SCSS files shall be referenced through the Media class, or media property, the SASS processor can be used directly.

Additionally, django-sass-processor is shipped with a management command, which can convert the content of all occurrences inside the templatetag sass_src as an offline operation. Hence the libsass compiler is not required in a production environment.

During development, a sourcemap is generated along side with the compiled *.css file. This allows to debug style sheet errors much easier.

With this tool, you can safely remove your Ruby installations "Compass" and "SASS" from your Django projects. You neither need any directory "watching" daemons based on node.js.

Project's Home

On GitHub:

https://github.com/jrief/django-sass-processor

Please use the issue tracker to report bugs or propose new features.

Installation

pip install libsass django-compressor django-sass-processor

django-compressor is required only for offline compilation, when using the command manage.py compilescss.

libsass is not required on the production environment, if SASS/SCSS files have been precompiled and deployed using offline compilation.

Configuration

In settings.py add to:

INSTALLED_APPS = [
    ...
    'sass_processor',
    ...
]

django-sass-processor is shipped with a special finder, to locate the generated *.css files in the directory referred by STORAGES['sass_processor']['ROOT'] (for Django >= 4.2.) or SASS_PROCESSOR_ROOT (for Django <= 4.1.), or, if unset STATIC_ROOT. Just add it to your settings.py. If there is no STATICFILES_FINDERS in your settings.py don't forget to include the Django default finders.

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'sass_processor.finders.CssFinder',
    ...
]

Optionally, add a list of additional search paths, the SASS compiler may examine when using the @import "..."; statement in SASS/SCSS files:

import os

SASS_PROCESSOR_INCLUDE_DIRS = [
    os.path.join(PROJECT_PATH, 'extra-styles/scss'),
    os.path.join(PROJECT_PATH, 'node_modules'),
]

Additionally, django-sass-processor will traverse all installed Django apps (INSTALLED_APPS) and look into their static folders. If any of them contain a file matching the regular expression pattern ^_.+\.(scss|sass)$ (read: filename starts with an underscore and is of type scss or sass), then that app specific static folder is added to the libsass include dirs. This feature can be disabled in your settings with:

SASS_PROCESSOR_AUTO_INCLUDE = False

If inside of your SASS/SCSS files, you also want to import (using @import "path/to/scssfile";) files which do not start with an underscore, then you can configure another Regex pattern in your settings, for instance:

SASS_PROCESSOR_INCLUDE_FILE_PATTERN = r'^.+\.scss$'

will look for all files of type scss. Remember that SASS/SCSS files which start with an underscore, are intended to be imported by other SASS/SCSS files, while files starting with a letter or number are intended to be included by the HTML tag <link href="{% sass_src 'path/to/file.scss' %}" ...>.

During development, or when SASS_PROCESSOR_ENABLED = True, the compiled file is placed into the folder referenced by STORAGES['sass_processor']['ROOT'] (for Django >= 4.2.) or SASS_PROCESSOR_ROOT (for Django <= 4.1.). If unset, this setting defaults to STATIC_ROOT. Having a location outside of the working directory prevents to pollute your local static/css/... directories with auto-generated files. Therefore assure, that this directory is writable by the Django runserver.

Fine tune SASS compiler parameters in settings.py.

Integer SASS_PRECISION sets floating point precision for output css. libsass' default is 5. Note: bootstrap-sass requires 8, otherwise various layout problems will occur.

SASS_PRECISION = 8

SASS_OUTPUT_STYLE sets coding style of the compiled result, one of compact, compressed, expanded, or nested. Default is nested for DEBUG and compressed in production.

Note: libsass-python 0.8.3 has problem encoding result while saving on Windows, the issue is already fixed and will be included in future pip package release, in the meanwhile avoid compressed output style.

SASS_OUTPUT_STYLE = 'compact'

Jinja2 support

sass_processor.jinja2.ext.SassSrc is a Jinja2 extension. Add it to your Jinja2 environment to enable the tag sass_src, there is no need for a load tag. Example of how to add your Jinja2 environment to Django:

In settings.py:

TEMPLATES = [{
    'BACKEND': 'django.template.backends.jinja2.Jinja2',
    'DIRS': [],
    'APP_DIRS': True,
    'OPTIONS': {
        'environment': 'yourapp.jinja2.environment'
    },
    ...
}]

Make sure to add the default template backend, if you're still using Django templates elsewhere. This is covered in the Upgrading templates documentation.

In yourapp/jinja2.py:

# Include this for Python 2.
from __future__ import absolute_import

from jinja2 import Environment


def environment(**kwargs):
    extensions = [] if 'extensions' not in kwargs else kwargs['extensions']
    extensions.append('sass_processor.jinja2.ext.SassSrc')
    kwargs['extensions'] = extensions

    return Environment(**kwargs)

If you want to make use of the compilescss command, then you will also have to add the following to your settings:

from yourapp.jinja2 import environment

COMPRESS_JINJA2_GET_ENVIRONMENT = environment

Usage

In your Django templates

{% load sass_tags %}

<link href="{% sass_src 'myapp/css/mystyle.scss' %}" rel="stylesheet" type="text/css" />

The above template code will be rendered as HTML

<link href="/static/myapp/css/mystyle.css" rel="stylesheet" type="text/css" />

You can safely use this templatetag inside a Sekizai's {% addtoblock "css" %} statement.

In Media classes or properties

In Python code, you can access the API of the SASS processor directly. This for instance is useful in Django's admin or form framework.

from sass_processor.processor import sass_processor

class SomeAdminOrFormClass(...):
    ...
    class Media:
        css = {
            'all': [sass_processor('myapp/css/mystyle.scss')],
        }

Add vendor prefixes to CSS rules using values from https://caniuse.com/

Writing SCSS shall be fast and easy and you should not have to care, whether to add vendor specific prefixes to your CSS directives. Unfortunately there is no pure Python package to solve this, but with a few node modules, we can add this to our process chain.

As superuser install

npm install -g npx

and inside your project root, install

npm install postcss-cli autoprefixer

Check that the path of node_modules corresponds to its entry in the settings directive STATICFILES_DIRS (see below).

In case npx can not be found in your system path, use the settings directive NODE_NPX_PATH = /path/to/npx to point to that executable.

If everything is setup correctly, django-sass-processor adds all required vendor prefixes to the compiled CSS files. For further information, refer to the Autoprefixer package.

To disable autoprefixing, set NODE_NPX_PATH = None.

Important note: If npx is installed, but postcss and/or autoprefixer are missing in the local node_modules, setting NODE_NPX_PATH to None is manadatory, otherwise django-sass-processor does not know how to postprocess the generated CSS files.

Offline compilation

If you want to precompile all occurrences of your SASS/SCSS files for the whole project, on the command line invoke:

./manage.py compilescss

This is useful for preparing production environments, where SASS/SCSS files can't be compiled on the fly.

To simplify the deployment, the compiled *.css files are stored side-by-side with their corresponding SASS/SCSS files. After compiling the files run

./manage.py collectstatic

as you would in a normal deployment.

In case you don't want to expose the SASS/SCSS files in a production environment, deploy with:

./manage.py collectstatic --ignore=*.scss

To get rid of the compiled *.css files in your local static directories, simply reverse the above command:

./manage.py compilescss --delete-files

This will remove all occurrences of previously generated *.css files.

Or you may compile results to the STORAGES['sass_processor']['ROOT'] [Django >= 4.2.] or SASS_PROCESSOR_ROOT [Django <= 4.1.] directory directy (if not specified - to STATIC_ROOT):

./manage.py compilescss --use-storage

Combine with --delete-files switch to purge results from there.

If you use an alternative templating engine set its name in --engine argument. Currently django and jinja2 are supported, see django-compressor documentation on how to set up COMPRESS_JINJA2_GET_ENVIRONMENT to configure jinja2 engine support.

During offline compilation django-sass-processor parses all Python files and looks for invocations of sass_processor('path/to/sassfile.scss'). Therefore the string specifying the filename must be hard coded and shall not be concatenated or being somehow generated.

Alternative templates

By default, django-sass-processor will locate SASS/SCSS files from .html templates, but you can extend or override this behavior in your settings with:

SASS_TEMPLATE_EXTS = ['.html','.jade']

Configure SASS variables through settings.py

In SASS, a nasty problem is to set the correct include paths for icons and fonts. Normally this is done through a _variables.scss file, but this inhibits a configuration through your projects settings.py.

To avoid the need for duplicate configuration settings, django-sass-processor offers a SASS function to fetch any arbitrary configuration directive from the project's settings.py. This is specially handy to set the include path of your Glyphicons font directory. Assume, Bootstrap-SASS has been installed using:

npm install bootstrap-sass

then locate the directory named node_modules and add it to your settings, so that your fonts are accessible through the Django's django.contrib.staticfiles.finders.FileSystemFinder:

STATICFILES_DIRS = [
    ...
    ('node_modules', '/path/to/your/project/node_modules/'),
    ...
]

NODE_MODULES_URL = STATIC_URL + 'node_modules/'

With the SASS function get-setting, it is possible to override any SASS variable with a value configured in the project's settings.py. For the Glyphicons font search path, add this to your _variables.scss:

$icon-font-path: unquote(get-setting(NODE_MODULES_URL) + "bootstrap-sass/assets/fonts/bootstrap/");

and @import "variables"; whenever you need Glyphicons. You then can safely remove any font references, such as <link href="/path/to/your/fonts/bootstrap/glyphicons-whatever.ttf" ...> from you HTML templates.

Configure SASS variables through Python functions

It is even possible to call Python functions from inside any module. Do this by adding SASS_PROCESSOR_CUSTOM_FUNCTIONS to the project's settings.py. This shall contain a mapping of SASS function names pointing to a Python function name.

Example:

SASS_PROCESSOR_CUSTOM_FUNCTIONS = {
    'get-color': 'myproject.utils.get_color',
}

This allows to invoke Python functions out of any *.scss file.

$color: get-color(250, 10, 120);

Here we pass the parameters '250, 10, 120' into the function def get_color(red, green, blue) in Python module myproject.utils. Note that this function receives the values as sass.Number, hence extract values using red.value, etc.

If one of these customoized functions returns a value, which is not a string, then convert it either to a Python string or to a value of type sass.SassNumber. For other types, refer to their documentation.

Such customized functions must accept parameters explicilty, otherwise sass_processor does not know how to map them. Variable argument lists therefore can not be used.

Error reporting

Whenever django-sass-processor runs in debug mode and fails to compile a SASS/SCSS file, it raises a sass.CompileError exception. This shows the location of the error directly on the Django debug console and is very useful during development.

This behaviour can be overridden using the settings variable SASS_PROCESSOR_FAIL_SILENTLY. If it is set to True, instead of raising that exception, the compilation error message is send to the Django logger.

Using other storage backends for compiled CSS files

Under the hood, SASS processor will use any storage configured in your settings as STORAGES['staticfiles']. This means you can use anything you normally use for serving static files, e.g. S3.

A custom Storage class can be used if your deployment needs to serve generated CSS files from elsewhere, e.g. when your static files storage is not writable at runtime and you nede to re-compile CSS in production. To use a custom storage, configure it in STORAGES['sass_processor']['BACKEND']. You can also configure a dictionary with options that will be passed to the storage class as keyword arguments in STORAGES['sass_processor']['OPTIONS'] [Django >= 4.2.] or SASS_PROCESSOR_STORAGE_OPTIONS [Django <= 4.1.>] (e.g. if you want to use FileSystemStorage, but with a different location or base_url:

# For Django >= 4.2.*
STORAGES['sass_processor'] = {
    'BACKEND': 'django.core.files.storage.FileSystemStorage',
    'OPTIONS': {
        'location': '/srv/media/generated',
        'base_url': 'https://media.myapp.example.com/generated'
    }
}

# For Django <= 4.1.*
SASS_PROCESSOR_STORAGE = 'django.core.files.storage.FileSystemStorage'
SASS_PROCESSOR_STORAGE_OPTIONS = {
    'location': '/srv/media/generated',
    'base_url': 'https://media.myapp.example.com/generated'
}

Amazon's S3 Storage

Using the S3 storage backend from django-storages with its regular configuration (if you do not otherwise use it for service static files):

# For Django >= 4.2.*
STORAGES['sass_processor'] = {
    'BACKEND': 'storages.backends.s3boto3.S3Boto3Storage'
}

# For Django <= 4.1.*
SASS_PROCESSOR_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

Heroku

If you are deploying to Heroku, use the heroku-buildpack-django-sass buildpack to automatically compile scss for you.

Development

To run the tests locally, clone the repository, and, in your local copy, create a new virtualenv. these commands:

python -m pip install --upgrade pip
pip install Django
pip install -r tests/requirements.txt
python -m pytest tests

django-sass-processor's People

Contributors

0yi0 avatar alorence avatar andreasbackx avatar be-ndee avatar bit avatar bojankogoj avatar bruunotrindade avatar cclauss avatar craiga avatar dainex avatar dorivard avatar emirotin avatar eshellman avatar frostbtn avatar jamezpolley avatar jrief avatar mouse-reeve avatar natureshadow avatar rfleschenberg avatar roansong avatar sandyrogers avatar schanq avatar terceiro avatar washeck avatar zagrebelin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-sass-processor's Issues

CSS files don't load

If there are no generated CSS files, they are generated but don't load after first dev server start (the browser gets 404). Only after restarting dev server they load.
Django 1.9.3, django-sass-processor 0.3.4

Django Compressor

Can you explain how this enables offline compression with sekizai and django-compressor?

Always getting TypeError at /

I tried Python2 and Python3, but I keep getting the same problem on my view

TypeError at /
filename must be a string, not None
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.5
Exception Type: TypeError
Exception Value:
filename must be a string, not None

I must have missed something, but I cannot figure out what it is.
I followed all the steps in the readme, but still having this issue.

I think it is not finding my scss file, but I cannot figure out which item in my settings.py relates to that file

Any advice?

PS: I dont think this is an issue per se, but rather me missing something in my config etc (Not sure how else to ask a question though)

django 1.8?

Hi
Is this version ready for Django 1.8 or 1.9?
I've got this error:

$ ./manage.py compilescss

Traceback (most recent call last):
  File "./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
    utility.execute()
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 343, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 31, in handle
    templates = self.find_templates()
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 42, in find_templates
    for loader in self.get_loaders():
  File "/home/guest007/.virtualenvs/1/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 66, in get_loaders
    from django.template.loader import (find_template_source as finder_func)
ImportError: cannot import name find_template_source

how to use SassS3Boto3Storage

As far as I can tell, SassS3Boto3Storage is provided only for use as a django-sass-processor compatible STATICFILES_STORAGE. It isn't ever used for the SassProcessor. So in a deployment where it is desired for css files to be served by S3, the css files must first be generated into a FileSystemStorage (into writeable directories) and then moved to S3 by collectstatic, via STATICFILES_STORAGE using the sass-compatibility class. This seems like an non-intuitive way to integrate django storages, and may be hard to maintain. It would be better to instead use SassFileStorage as a compatibility layer around a configurable storage backend.

Perhaps documentation of this could be added.

django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Im using django 1.9.5, & whenever I include the package in INSTALLED_APP, I got this error:

...site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Incompatibility with django-compressor 2.1

django-compressor released a breaking change to their interface from
compressor.offline.django.DjangoParser.get_nodelist(self, node, original)
to
compressor.offline.django.DjangoParser.get_nodelist(self, node, original, context)

so sass_processor.management.commands.compilescss.Command.walk_nodes() is now broken.

I see no easy way to make this change backward compatible with django-compressor <= 2.0 and Python 2, as the introspection API to get callable's signature was also changed. I suppose, the best course of actions is to ask django-compressor to make this context argument have a default value (None).

(I'm ended up with hard switching to compressor 2.1, as I no longer need 2.0 compatibility)

Output caching is effectively disabled in Windows

sass_processor.processor.SassProcessor.is_latest has this code:

           components = os.path.normpath(srcfilename).split(os.path.sep)
           srcfilename = ''.join([os.path.sep + c for c in components if c != os.path.pardir])

And this os.path.sep inside the join makes a priori invalid path in Windows (like /d:/path/path), so os.path.isfile what follows always returns False, forcing full compilation on every page request (when SASS_PROCESSOR_ENABLED is True, i.e. in development).

I can't seem to track down why this code is here. Does libsass generate some strange paths in their map file?

Removing these lines makes everything work as expected... in Windows. I have no easy way to test it on *nix, hence the question.

Error loading template: 'crispy_forms_tags' is not a registered tag library

Hi,

I'm sorry for the issue title. I couldn't think of a better title.

I get the following error message when running ./manage.py compilescss:

Invalid template [...]/venv/local/lib/python2.7/site-packages/rest_framework/
templates/rest_framework/filters/django_filter_crispyforms.html: 
'crispy_forms_tags' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_static
admin_urls
bootstrap3
cache
compress
future
i18n
l10n
log
rest_framework
sass_tags
static
staticfiles
tz

The application uses Django REST framework, but not django-crispy-forms (it's an optional dependency). I figured out that django-sass-processor loads all templates to look for sass_src tags (sass_processor/management/commands/compilescss.py#L85). This means mean the django-crispy-forms templates included with Django REST framework also get loaded even if we're not using them.

After thinking for a while I thought a template blacklist would be a good solution. What do you think about it?

Thanks,
Frank

New release to PyPI

Would you consider making a new release to PyPI? The django.template.base.TemplateDoesNotExist: test is in the current version there, and it's making this kinda useless for production use if installed from PyPI, which is a shame.

Thanks in advance, and thanks you for all the work :)

Cheers!

SassSrcNode.source is undefined

In SassSrcNode.source_file, it tries to use self.source which is not defined for me. Running Django 1.9.5, Python 3.5 and the Django template engine. The error causes it not to give the error stating that it cannot find the SCSS-file for the template.

Preprocessor stores css in STATIC_ROOT for development as well?

Hi Jacob, thanks for this very useful addition to the django family :)

I am probably doing something wrong so I ask just to be sure. I am testing you processor with a current project. I am working locally and the file is being processed and converted, but it is also being stored in the STATIC_ROOT. So the css is parsed but when I click on the link in the page source code (<link href="/static/css/base-style.css" rel="stylesheet" type="text/css" />), it reports a 404 error.

My static conf is:

STATIC_ROOT (`public/static`)
STATIC_URL = '/static/'

I have not used django-cms for such a long time, but I normally only get files dumped in my STATIC_ROOT, unless I ran collectstatic, so I do not know if this is a normal behavior, and if it is, how would I get it to work for local development?

Cheers

Installation via pip3 fails

I'm trying to install django-sass-processor via pip3, but I always get this error:

Downloading/unpacking django-sass-processor
  Downloading django-sass-processor-0.3.0.tar.gz
  Running setup.py (path:/tmp/pip_build_root/django-sass-processor/setup.py) egg_info for package django-sass-processor
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/django-sass-processor/setup.py", line 39, in <module>
        long_description=convert('README.md', 'rst'),
      File "/tmp/pip_build_root/django-sass-processor/setup.py", line 11, in convert
        return fd.read()
      File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 782: ordinal not in range(128)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/django-sass-processor/setup.py", line 39, in <module>

    long_description=convert('README.md', 'rst'),

  File "/tmp/pip_build_root/django-sass-processor/setup.py", line 11, in convert

    return fd.read()

  File "/usr/lib/python3.4/encodings/ascii.py", line 26, in decode

    return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 782: ordinal not in range(128)

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/django-sass-processor
Storing debug log for failure in /root/.pip/pip.log

But it's a bit strange: this only happens inside docker containers (fedora:23 and ubuntu:14.04) but on my native fedora 23 it is working fine. Can this problem be caused by missing dependencies? Do you know the dependencies?

And I read in # 18 that you

... didn't expect it being wildly used.

I'm currently setting up a new Website. Should I use django-sass-processor or should I search for another project?

Can't install on non-English Windows.

Sorry for my English.
I have problem with installation.

Log:
C:\Users\MyUser\PycharmProjects\scss_test>pip install django-sass-processor
Collecting django-sass-processor
Using cached django-sass-processor-0.3.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "C:\Users\MyUser\AppData\Local\Temp\pip-build-52so00wf\django-sass-processor\setup.py", line 39, in
long_description=convert('README.md', 'rst'),
File "C:\Users\MyUser\AppData\Local\Temp\pip-build-52so00wf\django-sass-processor\setup.py", line 11, in convert
return fd.read()
File "C:\Python34\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 794: character maps to
----------------------------------------
←[31mCommand "python setup.py egg_info" failed with error code 1 in C:\Users\MyUser\AppData\Local\Temp\pip-build-52so00wf\django-sass-processor←[0m

And I have a solution:
in setup.py need replace
with open(filename, 'r') as fd:
to
with open(filename, 'r', encoding='UTF-8') as fd:

I already tried this on my fork and its work!

Unable to locate file main.scss while rendering tag 'sass_src' in template index.html

I am unable to make things work and can't figure out why I am getting this error.

1. I have located the files in the static folder with the attached structure.
screen shot 2017-12-09 at 3 34 46 pm

2. In index.html, if I place a .css file at the same location as the main.scss and call it using {% static %} in a tag it works just fine. But I get the error in the subject when trying to call using sass_src:

<!DOCTYPE html>
{% load sass_tags %}
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Index</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="{% sass_src 'main.scss' %}" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->
        <h1>Hello</h1>
    </body>
</html>

3. The settings.py is as follows:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'debug_toolbar',
    'sass_processor',
]

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',
            ],
        },
    }, 
]

STATIC_URL = '/static/'

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 

SASS_PRECISION = 8

Issue with S3 storage using django-storages

When attempting to store static files on S3 using the django-storages package, I get the following traceback.

Traceback (most recent call last):
  File "tutorial_site/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/virtualenvs/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/opt/virtualenvs/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute
    django.setup()
  File "/opt/virtualenvs/venv/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/virtualenvs/venv/lib/python3.5/site-packages/django/apps/registry.py", line 116, in populate
    app_config.ready()
  File "/opt/virtualenvs/venv/lib/python3.5/site-packages/sass_processor/apps.py", line 24, in ready
    static_dir = os.path.join(app_config.path, self._storage.base_url.strip(os.path.sep))
AttributeError: 'S3Boto3Storage' object has no attribute 'base_url'

This appears to be caused by this line in apps.py where the current storage class' base_url is accessed. The problem is the S3Boto3Storage class doesn't appear to define this attribute/property.

Any help with this issue would be much appreciated.

compilescss does not support jinja2

I wanted to add support for the compilescss command because currently the command does not support jinja2. There have been a lot of changes in django-compressor's compress command which added support for jinja2 since the compilescss here was written based on that one. I think we/I should refactor the command and inherit from the compress command. This way we can follow the changes there. The current command on django-compressor is very messy, I think it's best to refactor that on their end first and then inherit it here, but add some changes so instead of compressing it would compile SCSS.

It might also be good to add to the readme that setting SASS_PROCESSOR_ENABLED is the only way to use Jinja2 with DEBUG set to False.

Command won't compile

Hi,

I am using: Python 2.7, Django 1.9.7, django-sass-processor 0.4.1
On my local env, I have no issues seeing my scss, along with the css and css-map, everything is fine (which makes me thing my settings.py is correct)
But when I run python manage.py compilescss I get the following error:

  File "xxx/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 65, in handle
    self.parse_template(template_name)
  File "xxx/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 182, in parse_template
    self.compile(node)
  File "xxx/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 194, in compile
    'include_paths': node.include_paths,
AttributeError: 'SassSrcNode' object has no attribute 'include_paths'

Could you help me?
Thanks,

Adding a CONTRIBUTING.md

I noticed that in the project single and double quotes are used interchangeably. (The majority is single quotes it seems.) This together with adding documentation would be beneficial to the project and I think we should start put all of this information in CONTRIBUTING.md so we and other can refer to it.

The choice for docstrings is Numpy or Google style? I've always used the Google one, what do you think?

Then I would just say that the code has to conform with PEP8 but not with the max 80 character rule. Rather I would say conform with a ~90 char rule. I would love to refer you to this talk from Raymond Hettinger about PEP8 that talks about this.

ImportError: No module named 'sass_processor'

Hi! I'm following the instructions in readme, I've succesfully installed django-sass-processor with pip, I'm trying to run server and getting the following error:

 ImportError: No module named 'sass_processor'

Am I missing something? What am I doing wrong?

It doesn't seem to be autocompiling... Or do I understand it wrong?

I'm certainly new to Django, and I don't really know how it loads the apps declared on settings.py, but following the few steps on the README (that is, installing dependencies, adding it as an app on settings.py) and placing

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')

I got it to work... But it compiles only when I call the runserver command (or the compilescss command)... Shouldn't it watch the files to see if something changed and compile them at some point? Or did I misunderstand the process?

Jinja2 rises TemplateSyntaxError if a variable is passed

I have a project that shares most of the template code base among few deployments. To differentiate i set all the project template variables in a external file. When i pass a variable to sass_src Exception is risen.

{% set PROJECT_SASS_FILE = 'xxx.scss' %} {%if PROJECT_SASS_FILE%} {% sass_src PROJECT_SASS_FILE %} {%endif%}

can't compile input[type=url]

I'm trying to compile the materialize project but it only compiles when I remove the input[type=url] line

input[type=text]:not(.browser-default),
input[type=password]:not(.browser-default),
input[type=email]:not(.browser-default),
input[type=url]:not(.browser-default),  // I have to remove this line to compile it
input[type=time]:not(.browser-default),
input[type=date]:not(.browser-default),
input[type=datetime]:not(.browser-default),
input[type=datetime-local]:not(.browser-default),
input[type=tel]:not(.browser-default),
input[type=number]:not(.browser-default),
input[type=search]:not(.browser-default),
textarea.materialize-textarea { // rules go here }

This is the trace

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 103, in handle
    self.parse_template(template_name)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 269, in parse_template
    self.compile_sass(sass_filename)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 287, in compile_sass
    content = sass.compile(**compile_kwargs)
  File "/Users/SDX/Documents/Django/env_keydex/lib/python2.7/site-packages/sass.py", line 640, in compile
    raise CompileError(v)
sass.CompileError: Error: Invalid CSS after "}": expected 1 selector or at-rule, was "input[type=text]:no"
        on line 20 of keydex/static/sass/components/forms/_input-fields.scss
>> }

Deprecated OptionParser use in management command

. venv/bin/activate ; python manage.py compilescss
venv/local/lib/python2.7/site-packages/django/core/management/base.py:265: RemovedInDjango110Warning: OptionParser usage for Django management commands is deprecated, use ArgumentParser instead
  RemovedInDjango110Warning)

use of django_sass_processor without libsass

In the documentation, you say

libsass is not required on the production environment, if SASS/SCSS files have been precompiled and deployed using offline compilation.

I don't understand this sentence. If libsass is not installed on the server, the tag sass_src won't work because it raises an importError.

So how can we use django_sass_processor in the production environment without using this tag? Is there really a way to use django_sass_processor without libsass?

Thanks for your work!

Please review branch auto-include-dirs

@AndreasBackx maybe this is an interesting new feature for version 0.5? Would you please be so kind and review it.

From the docs:

Additionally, django-sass-processor will traverse all installed Django apps and look into their
static folders. If any of them contain a file starting with a _ (underscore) and ending in
.scss or .sass, then that app specific static folder is added to the include paths.

django 1.9 support

python manage.py compilescss
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 195, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/django/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 39, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/django/venv/local/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 9, in <module>
    from django.utils.importlib import import_module
ImportError: No module named importlib

See http://stackoverflow.com/questions/29931979/recommended-practice-for-using-import-module-in-django-1-8 as well

Unable to locate file

I have the examples set up according to the guide but get Unable to locate file issues.

sass_src doesn't work in the template and whenever it's included it throws this error:

Unable to locate file mysite/static/main.scss while rendering tag 'sass_src' in template

I am trying to run this on a basic django_cms build

Possibly I am missing something that wasn't included in the readme

I cannot make it work using a basic structure

I don't really like the idea of having my scss files on a public static folder, but it seems to be the default. I have tried the following structure in my project:

/my-project/my-project/scss/styles.scss
/my-project/my-project/static/css/styles.css (autogenerated)
/my-project/my-project/templates/layout.html

This is my config in settings.py:

BASE_DIR = '/var/www/my-project'
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'sass_processor.finders.CssFinder'
]
SASS_PRECISION = 8

SASS_PROCESSOR_INCLUDE_DIRS = [
    os.path.join(BASE_DIR, 'my-project/scss'),
]

And this is the link withinlayout.html:

<link href="{% sass_src 'styles.scss' %}" rel="stylesheet" type="text/css" />

But when running python manage.py compilescss 0 files are compiled.
Could you help me out to find what is wrong in my config?
When I use {% sass_src 'styles.scss' %} the file "styles.scss" will be searched using the SASS_PROCESSOR_INCLUDE_DIRS right? Or there is no chance to keep the SCSS files outside from the static folder?

compilescss not finding calls of sass_processor within a dict

With the following code, the "compilescss" script does not recognise the scss to be compiled and does not create a css file:

@property
def media(self):
        parent_media = super().media
        parent_media._css['all'] = list(parent_media['all']) if 'all' in parent_media._css else []
        parent_media._css['all'].append(sass_processor('admin/glossary.scss'))
        return parent_media

When i am calling the sass_processor directly in the function and assign it to a variable, it correctly creates the css file:

@property
def media(self):
        parent_media = super().media
        parent_media._css['all'] = list(parent_media['all']) if 'all' in parent_media._css else []

        glossary_css = sass_processor('admin/glossary.scss')
        parent_media._css['all'].append(glossary_css)
        return parent_media

Invalid template name in 'extends' tag

compilescss give:

Invalid template name in 'extends' tag:

Error parsing template /Users/malt/Env/py3.5/lib/python3.5/site-packages/cms/templates/cms/dummy.html: Invalid template name in 'extends' tag: ''. Got this from the 'template' variable.

Error parsing template /Users/malt/Env/py3.5/lib/python3.5/site-packages/menus/templates/menu/dummy.html: Invalid template name in 'extends' tag: ''. Got this from the 'template' variable.

Support for STATICFILES_DIRS

Currently SassFileStorage, a subclass of FileSystemStorage, is being used to pass to the CssFinder. There should be a way to get it to work with STATICFILES_DIRS so it looks in multiple folders. This would allow for a per-app scss/sass folder. I came across this while working on the Jinja extension.

ImportError: No module named django.conf in docker-compose

Hi, I'm using docker-compose, and this is the secod time I build the container (the first works), If I try to install it in my local works, the problem is only when I build the container.

The error is:

▶ docker-compose build
db uses an image, skipping
Building web
Step 1 : FROM python:2.7
 ---> a047e3d0ae2b
Step 2 : ENV PYTHONUNBUFFERED 1
 ---> Using cache
 ---> 1185562aa2c3
Step 3 : RUN mkdir /code
 ---> Using cache
 ---> 9b6b22a35407
Step 4 : WORKDIR /code
 ---> Using cache
 ---> d57a69ce00c8
Step 5 : ADD requirements.txt /code/
 ---> Using cache
 ---> 391d56eb9d7e
Step 6 : RUN pip install -r requirements.txt
 ---> Running in 091eb695aaa0
Collecting Django==1.9.7 (from -r requirements.txt (line 1))
  Downloading Django-1.9.7-py2.py3-none-any.whl (6.6MB)
Collecting django-appconf==1.0.2 (from -r requirements.txt (line 2))
  Downloading django_appconf-1.0.2-py2.py3-none-any.whl
Collecting django-compressor==2.0 (from -r requirements.txt (line 3))
  Downloading django_compressor-2.0-py2.py3-none-any.whl (120kB)
Collecting django-friendly-tag-loader==1.2.1 (from -r requirements.txt (line 4))
  Downloading django_friendly_tag_loader-1.2.1-py2.py3-none-any.whl
Collecting django-sass-processor==0.4.0 (from -r requirements.txt (line 5))
  Downloading django-sass-processor-0.4.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-jJV1Sj/django-sass-processor/setup.py", line 6, in <module>
        from sass_processor import __version__
      File "/tmp/pip-build-jJV1Sj/django-sass-processor/sass_processor/__init__.py", line 25, in <module>
        from .processor import SassProcessor
      File "/tmp/pip-build-jJV1Sj/django-sass-processor/sass_processor/processor.py", line 6, in <module>
        from django.conf import settings
    ImportError: No module named django.conf

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-jJV1Sj/django-sass-processor/
ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1

My Dockerfile:

FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/

And the docker-compose.yml:

version: '2'
services:
  db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: "...."
      MYSQL_DATABASE: "Proyect"
      MYSQL_USER: "proyect"
      MYSQL_PASSWORD: "...."
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

Versions:

django-appconf==1.0.2
django-compressor==2.0
django-friendly-tag-loader==1.2.1
django-sass-processor==0.4.0
django-social-auth==0.7.28
djangorestframework==3.3.3
django-sass-processor==0.4.0
libsass==0.11.1

css.map

is the "source" key suppose to be a relative directory?
{
"version": 3,
"file": "../../../../ui/static/scss/demo3.css",
"sources": [
"../../../../ui/static/scss/demo3.scss"
],
"mappings": "AAEA,AAEU,UAFA,CACN,WAAW,CACP,EAAE,AAAA,OAAO,AAAC,CACN,KAAK,CALA,OAAO,CAMf",
"names": []
}

Integrating d-s-p with pip package containing django templates and sass_tags

Hello!

Huge fan of your work here - as a full stack dev specializing in front end, I'm quite pleased to see the latest and greatest technologies being leveraged throughout more and more platforms.

I have a django project containing several apps, one of which is a design app meant to house all the jinja2 templates, styles, javascript libraries - etc. We're planning to use this design app in several separate django projects within the same platform (base styles/shared templates/all that). I've managed to split out the design app into a self-sustained pip package but was having some issues with how {% load sass_tags %} works. Unfortunately it can't seem to parse the pip package template folder hierarchy correctly. Is there a setup I should be aware of? Any suggestions? I'd be happy to provide what I can in terms of source code for clarification.

Thanks so much!

Extensions for Jinja2 template support

The README mentions how to use the library for the commands, but there is no mention of it regarding templates. There doesn't seem to be an extension in the source, is there perhaps a function we can pass to the Jinja2 environment?

django.template.base.TemplateDoesNotExist: test

Hi,

I need help to understand why I cannot compile the scss for production environment.

Django==1.7.7
django-sass-processor==0.2.2
django-compressor==1.5

when trying to run the command line :

    python manage.py compilescss

I am getting this error:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "~/virtualenvs/blog/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "~/virtualenvs/blog/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "~/virtualenvs/blog/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "~/virtualenvs/blog/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "~/virtualenvs/blog/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 28, in handle
    templates = self.find_templates()
  File "~/virtualenvs/blog/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 39, in find_templates
    for loader in self.get_loaders():
  File "~/virtualenvs/blog/lib/python2.7/site-packages/sass_processor/management/commands/compilescss.py", line 68, in get_loaders
    finder_func('test')
  File "~/virtualenvs/blog/lib/python2.7/site-packages/django/template/loader.py", line 136, in find_template
    raise TemplateDoesNotExist(name)
django.template.base.TemplateDoesNotExist: test

When looking at the code, it pass by the line 61 of compilescss.py

from django.template.loader import (
                    find_template as finder_func)

and then it fails at line 68 of the same file which is in a try catch

        try:
            # Force Django to calculate template_source_loaders from
            # TEMPLATE_LOADERS settings, by asking to find a dummy template
            finder_func('test')
        except TemplateDoesNotExist:
            pass

Can you help me figure out why this is happening?

My settings are:

in INSTALLED_APPS
'sass_processor',
'compressor',

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
    'sass_processor.finders.CssFinder',
)

COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'django_libsass.SassCompiler'),
)

COMPRESS_ENABLED = False
COMPRESS_OFFLINE = True
SASS_PROCESSOR_ENABLED = True
SASS_PROCESSOR_ROOT = STATIC_ROOT + '/sass'



TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

I even tried to set SASS_PROCESSOR_ENABLED = False which didn't change anything.

Regards
Dominick

doesn't convert *.scss files into *.css

Hi.
I have the example set up according to the guide but sass_src doesn't work.
Сhecked settings but didn't find a problem.

$ pip list
Django (1.10.2)
django-compressor (2.1)
django-sass-processor (0.5.1)
libsass (0.11.2)
django-zurb-foundation-rtl (6.0.6.3)

My file settings.py:

BASE_DIR` = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'foundation',
    'sass_processor',
    'testapp',
]
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'sass_processor.finders.CssFinder',
 ]
SASS_PROCESSOR_ENABLED = True
SASS_PROCESSOR_ROOT = os.path.join(BASE_DIR, 'static_final')
SASS_OUTPUT_STYLE = 'compact'

In my Django template in directory BASE_DIR/testapp/templates/testapp/index.html:

{% load sass_tags %}
<link href="{% sass_src 'foundation/scss/foundation.scss' %}" rel="stylesheet" type="text/css" />

The directory BASE_DIR/static_final/foundation/scss/ contains two files:
foundation.css
foundation.css.map
foundation.zip

What do you think about it?

Thanks,
Alexey

`FileNotFoundError` not defined

Django 1.9+

NameError at /
global name 'FileNotFoundError' is not defined

Exception Value:     global name 'FileNotFoundError' is not defined

Here's the offender:

    templatetags/sass_tags.py
    38: except FileNotFoundError as e: 

Support for URL in STATIC_URL

I would like to serve static files from a subdomain, so normally I would set STATIC_URL = 'http://subdomain.example.com/.
But this does not seem to work with the sass processor. It expects that the STATIC_URL is only a URL path without hostname.
The domain would still be served from the same machine (or they would be precompiled anyways), so it would only need to support the mapping from filename -> url.

absolute paths in css.map file

Hi, related to 64 but only in parts.

The problem is that libsass generates absolute paths in css.map file. I found that on Windows, but probably on *nix too, if source_map_filename parameter starts with root / slash like /static/base.css.map as it always the case because of this line: L74 libsass create absolute paths. If the source_map_filename starts without slash like static/base.css.map the generated paths would be relative as they should.

python manage.py compilescss => ImportError: No module named utils

I'm trying to install this preprocessor, I followed the steps in the README and when running python manage.py compilescss it throw this error:

root@8d6966117fec:/opt/xos# python manage.py compilescss
Traceback (most recent call last):
  File "manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/sass_processor/management/commands/compilescss.py", line 57, in handle
    self.parser = self.get_parser(options['engine'])
  File "/usr/local/lib/python2.7/dist-packages/sass_processor/management/commands/compilescss.py", line 74, in get_parser
    from compressor.offline.django import DjangoParser
  File "/usr/local/lib/python2.7/dist-packages/compressor/offline/django.py", line 13, in <module>
    from compressor.templatetags.compress import CompressorNode
  File "/usr/local/lib/python2.7/dist-packages/compressor/templatetags/compress.py", line 5, in <module>
    from compressor.cache import (cache_get, cache_set, get_offline_hexdigest,
  File "/usr/local/lib/python2.7/dist-packages/compressor/cache.py", line 13, in <module>
    from compressor.conf import settings
  File "/usr/local/lib/python2.7/dist-packages/compressor/conf.py", line 5, in <module>
    from django.template.utils import InvalidTemplateEngineError
ImportError: No module named utils

While if I add:

{% load sass_tags %}
<link rel="stylesheet" type="text/css" href="{% sass_src "xos.scss" %}" />

It Throw Error 500 (with no hint also in the console)

Any hint to solve?

I'm running Django 1.7

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.