python – Django-sass-processor TypeError

前端之家收集整理的这篇文章主要介绍了python – Django-sass-processor TypeError前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

所以,我是Django的新手,并且不能为我的生活找出为什么我一直在我的视图上得到一个TypeError.

错误是:

  1. TypeError at /
  2. filename must be a string,not None
  3. Request Method: GET
  4. Request URL: http://127.0.0.1:8000/
  5. Django Version: 1.8.5
  6. Exception Type: TypeError
  7. Exception enter code hereValue:
  8. filename must be a string,not None

我在视图中有以下内容

我可能在settings.py中遗漏了一些东西,但不确定它是什么.另外,如何链接到我的scss文件

我在settings.py中添加了以下内容

  1. INSTALLED_APPS = [
  2. ....
  3. 'sass_processor',....
  4. ]
  5. STATICFILES_FINDERS = (
  6. 'sass_processor.finders.CssFinder',)

我想我的问题就在这里

  1. SASS_PROCESSOR_INCLUDE_DIRS = (
  2. os.path.join(BASE_DIR,'app_name/static'),)

BASE_DIR指的是

  1. BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

究竟应该指向哪里?我的app结构是

  1. app_dir/
  2. Specs/
  3. src/
  4. app_name/
  5. static/
  6. theme.scss
  7. templates/
  8. __init__.py
  9. views.py
  10. etc...

我认为这是一个Python3错误,所以我支持2.7 ve,但仍然有完全相同的问题.

最佳答案
我意识到这没有答案,但我确实找到了问题归功于jrief

这需要在设置文件

  1. INSTALLED_APPS = [
  2. ....
  3. 'sass_processor',....
  4. ]
  5. ....
  6. ....
  7. STATIC_ROOT = os.path.join(BASE_DIR,'app_name/static/')
  8. STATIC_URL = '/static/'

html中的链接

< link href =“{%sass_src'filename.scss'%}”rel =“stylesheet”type =“text / css”/>

这些都不是必需的

  1. SASS_PROCESSOR_INCLUDE_DIRS = (
  2. os.path.join(BASE_DIR,)
  3. STATICFILES_FINDERS = (
  4. 'sass_processor.finders.CssFinder',)

猜你在找的Python相关文章