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

来源:互联网 发布:vscode调试html插件 编辑:程序博客网 时间:2024/04/30 12:56

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

我在模板目录下的admin目录中建立了index.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取代,所以就不打算搞这个框架页面了.

 

 

 

原创粉丝点击