要实现的功能
http://imgur.com/EwGYIlK
在 base 页面使用了 regroup 做出来的
但是却在其他子页面不能显示
http://imgur.com/WGuIdtv
莫非 django 继承不能继承变量吗
要实现的功能
http://imgur.com/EwGYIlK
在 base 页面使用了 regroup 做出来的
但是却在其他子页面不能显示
http://imgur.com/WGuIdtv
莫非 django 继承不能继承变量吗
|
georgema1982Oct 22, 2016
1
变量不存在继承一说。在当前模板里一个变量有就有,没有就没有。
|
|
2
@georgema1982 哦这样啊,我得想办法让其他页面也能方便的显示了,先睡觉
|
|
gogobodyOct 22, 2016 via Android
3
我用过全局变量。。。
|
|
upczwwOct 22, 2016 via Smartisan T1
4
这样好像不能直接继承的,要不把变量再写一遍?
|
|
5
我觉得应该用上下文
|
|
phithonOct 22, 2016
6
写一个 context processor ?这样所有页面都会有这个变量了
http://djangobook.com/writing-context-processors/ Guidelines for Writing Your Own Context Processors |
|
7
@phithon nice
|