您的位置:首页 > 编程语言 > Go语言

[django]admin后台采用框架页面不行

2009-11-24 01:17 459 查看
今天试着将视图采用国内大部分cms的后台界面--frameset框架,但是调整了模板最后还是发现不行.

我在模板目录下的admin目录中建立了index.html,内容如下:

01 <html> 
02 <head> 
03 
04 <meta http-equiv=content-type content=text/html; charset=gb2312> 
05 <title>网站内容管理系统</title> 
06 <link rel="icon" href="pic/favicon.ico" mce_href="pic/favicon.ico" type="image/x-icon" /> 
07 <link rel="shortcut icon" href="pic/favicon.ico" mce_href="pic/favicon.ico" type="image/x-icon" /> 
08 <mce:script type="text/javascript"><!--
 
09 function changeDisplayMode(){ 
10     if(document.getElementById("bottomframes").cols=="180,7,*"){ 
11         document.getElementById("bottomframes").cols="0,7,*"; 
12         document.getElementById("separator").contentWindow.document.getElementById('ImgArrow').src="/Themes/Styles/Silver/separator2.gif" 
13     }else{ 
14         document.getElementById("bottomframes").cols="180,7,*" 
15         document.getElementById("separator").contentWindow.document.getElementById('ImgArrow').src="/Themes/Styles/Silver/separator1.gif" 
16     } 
17 } 
18 
// --></mce:script> 
19 </head> 
20 
21 <frameset id="mainframes" framespacing="0" border="false" rows="58,*" frameborder="0" scrolling="yes"> 
22 <frame name="top" scrolling="no" src="/admin/top/" mce_src="admin/top/"> 
23 <frameset id="bottomframes" framespacing="0" border="false" cols="180,7,*" frameborder="0" scrolling="yes"> 
24     <frame name="left" scrolling="auto" marginwidth="0" marginheight="0" src="/admin/left/" mce_src="admin/left/" noresize /> 
25     <frame id="separator" name="separator" src="/admin/separator/" mce_src="admin/separator/" noresize scrolling="no" /> 
26     <frame name="right" scrolling="auto" src="/admin/right/" mce_src="admin/right/"> 
27 </frameset> 
28 </frameset> 
29 
30 <noframes> 
31 <body > 
32 <p>This page uses frames, but your browser doesn't support them.</p> 
33 </body> 
34 </noframes> 
35 </html>


22 行 <frame name="top" scrolling="no" src="/admin/top/">,调用了一个为 /admin/top/ 的url,因此,我把整站的urls.py修改了



(r'^(?i)admin/docs/', include('django.contrib.admindocs.urls')),

(r'^(?i)admin/top/', direct_to_template, {'template': 'admin/top.html' }),
(r'^(?i)admin/left/', admin.site.index, {'extra_context': {'template': 'admin/left.html' } }),
(r'^(?i)admin/right/', direct_to_template, {'template': 'admin/right.html' }),

# Uncomment the next line to enable the admin1.0beta:
(r'^(?i)admin/(.*)', admin.site.root),
/admin/top/ 是直接调用了模板 admin/top.html,本来想在/admin/left/ 下显示众多app的列表,因此使用了admin.site.index 这个view来产生所需的app列表,但是发现分框架后,左边的还是显示了整个admin/ url下的页面,就是说左边的嵌套了整个上右左框架.后来试着加了字典:{'extra_context': {'template': 'admin/left.html' } }以为能够改变 /admin/left/ 的模板(就是模板的事情),却发现,admin app的sites.py文件中已经指定 了模板为 admin/index.html,如下:



context.update(extra_context or {})
return render_to_response(self.index_template or 'admin/index.html', context,
context_instance=template.RequestContext(request)
)
index = never_cache(index)

所以最后我放弃了把admin后台改造成框架式的,同时查阅了一些资料发现,framesets这种做法不是w3c所推荐的,而且随着ajax的流行,framesets的优点将会被ajax取代,所以就不打算搞这个框架页面了.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: