This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

django-pyscss

A collection of tools for making it easier to use pyScss within Django.

Note

This version only supports pyScss 1.3.4 and greater. For pyScss 1.2 support, you can use the 1.x series of django-pyscss.

Installation

django-pyscss supports Django 1.4+, and Pythons 2 and 3.

You may install django-pyscss off of PyPI:

pip install django-pyscss

Why do we need this?

This app smooths over a lot of things when dealing with pyScss in Django. It

  • Overwrites the import system to use Django’s staticfiles app. This way you can import SCSS files from any app (or any file that’s findable by the STATICFILES_FINDERS) with no hassle.
  • Configures pyScss to work with the staticfiles app for its image functions (e.g. inline-image and sprite-map).
  • It provides a django-compressor precompile filter class so that you can easily use pyScss with django-compressor without having to bust out to the shell. This has the added benefit of removing the need to configure pyScss through its command-line arguments AND makes it possible for the exceptions and warnings that pyScss emits to bubble up to your process so that you can actually know what’s going on.

Rendering SCSS manually

You can render SCSS manually from a string like this:

from django_pyscss import DjangoScssCompiler

compiler = DjangoScssCompiler()
compiler.compile_string(".foo { color: green; }")

You can render SCSS from a file like this:

from django_pyscss import DjangoScssCompiler

compiler = DjangoScssCompiler()
compiler.compile('css/styles.scss')

The file needs to be able to be located by staticfiles finders in order to be used.

The DjangoScssCompiler class is a subclass of scss.Compiler that injects the DjangoExtension. DjangoExtension is what overrides the import mechanism.

DjangoScssCompiler also turns on the CompassExtension by default, if you wish to turn this off you do so:

from django_pyscss import DjangoScssCompiler
from django_pyscss.extensions.django import DjangoExtension

compiler = DjangoScssCompiler(extensions=[DjangoExtension])

For a list of options that DjangoScssCompiler accepts, please see the pyScss API documentation.

Using in conjunction with django-compressor

django-pyscss comes with support for django-compressor. All you have to do is add it to your COMPRESS_PRECOMPILERS setting. :

COMPRESS_PRECOMPILERS = (
    # ...
    ('text/x-scss', 'django_pyscss.compressor.DjangoScssFilter'),
    # ...
)

Then you can just use SCSS like you would use CSS normally. :

{% compress css %}
<link rel="stylesheet" type="text/x-scss" href="{% static 'css/styles.css' %}">
{% endcompress %}

If you wish to provide your own compiler instance (for example if you wanted to change some settings on the DjangoScssCompiler), you can subclass DjangoScssFilter. :

# myproject/scss_filter.py
from django_pyscss import DjangoScssCompiler
from django_pyscss.compressor import DjangoScssFilter

class MyDjangoScssFilter(DjangoScssFilter):
    compiler = DjangoScssCompiler(
        # Example configuration
        output_style='compressed',
    )

# settings.py
COMPRESS_PRECOMPILERS = (
    # ...
    ('text/x-scss', 'myproject.scss_filter.MyDjangoScssFilter'),
    # ...
)

Running the tests

You can run the tests by running.

$ python setup.py test

Please note that this will collecstatic into tmp/static/ automatically as some of the tests require the staticfiles to have been collected.

CHANGELOG

2.0.2 (2015-04-29)

  • Fixed bug with relative imports [#34, #35 r1chardj0n3s]

2.0.1 (2015-04-23)

  • Explicitly depend on pathlib, instead of assuming pyScss will require it. [#33]
  • Fixed cases where DEBUG is False but collectstatic hasn’t been run (common in tests).

2.0.0 (2015-04-22)

  • Added support for pyScss 1.3 and Python 3.
  • Dropped support for pyScss 1.2

Upgrade path

If you are just using the django-compressor integration, you don’t have to upgrade anything.

If you were using the DjangoScss class directly, it has been replaced with the DjangoScssCompiler class. The API for compiling CSS has changed as well, for example, to compile from a string, previously you would do it like this:

>>> from django_pyscss.scss import DjangoScss
>>> compiler = DjangoScss()
>>> compiler.compile(".foo { color: red; }")

Now the interface is like this:

>>> from django_pyscss import DjangoScssCompiler
>>> compiler = DjangoScssCompiler()
>>> compiler.compile_string(".foo { color: red; }")

You read more about the new API on the pyScss API documentation.

1.0.0 - 2014-02-11

Released django-pyscss.

Release History

Release History

2.0.2

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

2.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.6

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.5

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.4

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-pyscss-2.0.2.tar.gz (17.8 kB) Copy SHA256 Checksum SHA256 Source Apr 29, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting