Skip to content

Instantly share code, notes, and snippets.

@mitsuhisaT
Created December 3, 2019 23:31
Show Gist options
  • Save mitsuhisaT/1b5b78b380f44827fc37b6f7d5971a19 to your computer and use it in GitHub Desktop.
Save mitsuhisaT/1b5b78b380f44827fc37b6f7d5971a19 to your computer and use it in GitHub Desktop.
How to modify Bootstrap4 sass in Django 3.0.

How to use Bootstrap4 Sass in Django 3.0

I set up Django 2.2 and Bootstrap4 Sass from the
'How to use SCSS/SASS in your Django project (Python Way)'.

But can't work Django 3.0.
This is one of resolution.

My testing environment is:
macOS High Sierra Version 10.13.6

prepare PyEnv Virtualenv

$ cd ~
$ pyenv virtualenv 3.7.5 dj3rpi375
$ cd your/django-rpi-tph-monitor/
$ pyenv local dj3rpi375

install Django 3.0 and others

$ pip install --upgrade Django
$ pip install --upgrade pip
$ pip install --upgrade djangorestframework
$ pip install --upgrade markdown
$ pip install --upgrade django-filter
$ pip install --upgrade drf-yasg
$ pip install --upgrade django-bootstrap4
$ pip install -e git://github.com/django-compressor/django-compressor.git@a5bfd775450428e1a261b88e1e5424bfb4dde081#egg=django_compressor
$ pip install --upgrade django-libsass

about django-compressor issue 963.

test

$ ./manage.py test monitor
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
........<BME280: BME280 object (None)>
<BME280: BME280 object (None)>
<BME280: BME280 object (None)>
<BME280: BME280 object (None)>
<BME280: BME280 object (None)>
.<BME280: BME280 object (None)>
.
----------------------------------------------------------------------
Ran 10 tests in 5.034s

OK
Destroying test database for alias 'default'...

But, can't display web page, because 'django_libsass.SassCompiler: command not found'.

resolution hint: from stackoverflow Django Sass Compressor django_libsass.SassCompiler: command not found

install part 2

uninstall django-libsass

$ pip uninstall django-libsass

install sassc

$ brew install sassc

modified settings.py

COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'pysassc {infile} {outfile}'),
)

Success!


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment