Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

sass - Use scss in django: scss compiled into css in CACHE "applyed" but "override" by default bootstrap theme

EDIT 1

to test, I just change primary from blue to purple

My scss seems to be compiled and get (return 200)

If I reload the page, I can see it is applyed as my primary button is briefly purple but immediatly "override" by intial blue color

what is wrong ? I try to see if other bootstrap css was loaded but no

enter image description here

app architecture

- static
     - bootstrap
     - CACHE
         - css
             - theme.7ba97bdae4cb.css
     - css
     - js
     - theme.scss

settings.py

STATIC_URL = '/static/'
STATIC_ROOT = 'static'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR,'project/static'),
)
STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
]

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

I find the previous issue came from DEBUG set in settings.py (I cast in int and to be honnest do not remember excatly why)


I want to use SCSS in my Django project running with Docker in order to customize bootstrap

I have follow this tutorial https://www.accordbox.com/blog/how-use-scss-sass-your-django-project-python-way/

First I had error while building docker container that I manage to resolve.

But when I run it, and try to reach home page, I got an error that seems to deal with connection

source_comments must be bool, not 1 with {% compress css %} tag

I run logs to complete trace but I do not understand but error does not deal with this...

thanks for help

Internal Server Error: /
web            | Traceback (most recent call last):
web            |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner
web            |     response = get_response(request)
web            |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response
web            |     response = self.process_exception_by_middleware(e, request)
web            |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response
web            |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
web            |   File "/usr/src/app/core/views.py", line 12, in home
web            |     return render(request, 'home.html', {
web            |   File "/usr/local/lib/python3.8/site-packages/django/shortcuts.py", line 36, in render
web            |     content = loader.render_to_string(template_name, context, request, using=using)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/loader.py", line 62, in render_to_string
web            |     return template.render(context, request)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render
web            |     return self.template.render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 171, in render
web            |     return self._render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/test/utils.py", line 96, in instrumented_test_render
web            |     return self.nodelist.render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 937, in render
web            |     bit = node.render_annotated(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 904, in render_annotated
web            |     return self.render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render
web            |     return compiled_parent._render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/test/utils.py", line 96, in instrumented_test_render
web            |     return self.nodelist.render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 937, in render
web            |     bit = node.render_annotated(context)
web            |   File "/usr/local/lib/python3.8/site-packages/django/template/base.py", line 904, in render_annotated
web            |     return self.render(context)
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/templatetags/compress.py", line 131, in render
web            |     return self.render_compressed(context, self.kind, self.mode, forced=forced)
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/templatetags/compress.py", line 107, in render_compressed
web            |     rendered_output = compressor.output(mode, forced=forced)
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/css.py", line 49, in output
web            |     ret.append(subnode.output(*args, **kwargs))
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/css.py", line 51, in output
web            |     return super(CssCompressor, self).output(*args, **kwargs)
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/base.py", line 295, in output
web            |     output = '
'.join(self.filter_input(forced))
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/base.py", line 235, in filter_input
web            |     for hunk in self.hunks(forced):
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/base.py", line 205, in hunks
web            |     precompiled, value = self.precompile(value, **options)
web            |   File "/usr/local/lib/python3.8/site-packages/compressor/base.py", line 276, in precompile
web            |     return True, filter.input(**kwargs)
web            |   File "/usr/local/lib/python3.8/site-packages/django_libsass.py", line 138, in input
web            |     return compile(filename=self.filename,
web            |   File "/usr/local/lib/python3.8/site-packages/django_libsass.py", line 125, in compile
web            |     output = sass.compile(**kwargs)
web            |   File "/usr/local/lib/python3.8/site-packages/sass.py", line 607, in compile
web            |     raise TypeError(
web            | TypeError: source_comments must be bool, not 1
web            | [28/Jan/2021 14:19:03] "GET / HTTP/1.1" 500 177528
web            | ----------------------------------------
web            | Exception happened during processing of request from ('127.0.0.1', 44218)
web            | Traceback (most recent call last):
web            |   File "/usr/local/lib/python3.8/socketserver.py", line 650, in process_request_thread
web            |     self.finish_request(request, client_address)
web            |   File "/usr/local/lib/python3.8/socketserver.py", line 360, in finish_request
web            |     self.RequestHandlerClass(request, client_address, self)
web            |   File "/usr/local/lib/python3.8/socketserver.py", line 720, in __init__
web            |     self.handle()
web            |   File "/usr/local/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 171, in handle
web            |     self.handle_one_request()
web            |   File "/usr/local/lib/python3.8/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request
web            |     self.raw_requestline = self.rfile.readline(65537)
web            |   File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
web            |     return self._sock.recv_into(b)
web            | ConnectionResetError: [Errno 104] Connection reset by peer
web            | ----------------------------------------

question from:https://stackoverflow.com/questions/65938129/use-scss-in-django-scss-compiled-into-css-in-cache-applyed-but-override-by

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...