Xut*_*ton 5 python django sass
所以,我是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
Run Code Online (Sandbox Code Playgroud)
我在视图中有以下内容
<!DOCTYPE html>
{% load sass_tags %}
<html>
<head lang="en">
...
<link href="{% sass_src 'app_name/static/theme.scss' %}" media="screen" rel="stylesheet" type="text/css">
Run Code Online (Sandbox Code Playgroud)
我可能在settings.py中遗漏了一些东西,但不确定它是什么.另外,如何链接到我的scss文件?
我在settings.py中添加了以下内容
INSTALLED_APPS = [
....
'sass_processor',
....
]
STATICFILES_FINDERS = (
'sass_processor.finders.CssFinder',
)
Run Code Online (Sandbox Code Playgroud)
我想我的问题就在这里
SASS_PROCESSOR_INCLUDE_DIRS = (
os.path.join(BASE_DIR, 'app_name/static'),
)
Run Code Online (Sandbox Code Playgroud)
BASE_DIR指的是
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Run Code Online (Sandbox Code Playgroud)
究竟应该指向哪里?我的app结构是
app_dir/
Specs/
src/
app_name/
static/
theme.scss
templates/
__init__.py
views.py
etc...
Run Code Online (Sandbox Code Playgroud)
我认为这是一个Python3错误,所以我支持2.7 ve,但仍然有完全相同的问题.
我意识到这个问题没有得到解答,但由于jrief,我确实找到了问题
这需要在设置文件中
INSTALLED_APPS = [
....
'sass_processor',
....
]
....
....
STATIC_ROOT = os.path.join(BASE_DIR, 'app_name/static/')
STATIC_URL = '/static/'
Run Code Online (Sandbox Code Playgroud)
html中的链接
<link href="{% sass_src 'filename.scss' %}" rel="stylesheet" type="text/css"/>
这些都不是必需的
SASS_PROCESSOR_INCLUDE_DIRS = (
os.path.join(BASE_DIR, 'app_name/static'),
)
STATICFILES_FINDERS = (
'sass_processor.finders.CssFinder',
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
451 次 |
| 最近记录: |