jrief / django-sass-processor Goto Github PK
View Code? Open in Web Editor NEWSASS processor to compile SCSS files into *.css, while rendering, or offline.
License: MIT License
SASS processor to compile SCSS files into *.css, while rendering, or offline.
License: MIT License
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": []
}
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.
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%}
@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.
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?
I would like the ability to set certain parameters on the sass compiler, example:
--compass -r font-awesome-sass
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.
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 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
.
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
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!
. 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)
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
Error: property "input" must be followed by a ':'
I believe this is a regression
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.
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
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
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.
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
Can you explain how this enables offline compression with sekizai and django-compressor?
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!
Hi, because of this line L24 APPS_INCLUDE_DIRS will be never filled.
Because of os.path.sep
, base_url
like /static/
don't will be striped and os.path.join
will produce C:\static\
path.
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.
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
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?
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!
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?
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.
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
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.
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.
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)
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
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?
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
>> }
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!
When deleting the CSS-file, it will not trigger a regeneration of the file. Only when deleting the map file or both will it regenerate both.
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
There is a problem in attaching css files while rendering templates so i have to use python manage.py compilescss
everytime.
I've set all the settings and still it doesn't work, btw it's a mac osx v10.11.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)
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.
It would be great to support the CachedStaticFilesStorage
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.
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.
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?
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
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:
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,
I would have thought that SASS_PROCESSOR_AUTO_INCLUDE = False would prevent the compilescss management command from looking in EVERY python source file for files to convert. But no, find_sources() looks everywhere, not just in APPS_INCLUDE_DIRS.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.