加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – Django-sass-processor TypeError

发布时间:2020-12-16 23:46:09 所属栏目:Python 来源:网络整理
导读:所以,我是Django的新手,并且不能为我的生活找出为什么我一直在我的视图上得到一个TypeError. 错误是: TypeError at /filename must be a string,not NoneRequest Method: GETRequest URL: http://127.0.0.1:8000/Django Version: 1.8.5Exception Type: Type

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

错误是:

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 enter code hereValue: 
filename must be a string,not None

我在视图中有以下内容

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

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

INSTALLED_APPS = [
    ....
    'sass_processor',....
]

STATICFILES_FINDERS = (
    'sass_processor.finders.CssFinder',)

我想我的问题就在这里

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

BASE_DIR指的是

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

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

app_dir/
    Specs/
    src/
        app_name/
            static/
                theme.scss
            templates/
            __init__.py
            views.py
  etc...

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

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

这需要在设置文件中

INSTALLED_APPS = [
....
'sass_processor',....
]

....
....

STATIC_ROOT = os.path.join(BASE_DIR,'app_name/static/')
STATIC_URL = '/static/'

html中的链接

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

这些都不是必需的

SASS_PROCESSOR_INCLUDE_DIRS = (
    os.path.join(BASE_DIR,)
STATICFILES_FINDERS = (
    'sass_processor.finders.CssFinder',)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读