django的简单fancybox模式
django-fancybox的Python项目详细描述
安装
pip install django-fancybox
外部依赖性
- jquery—包中不包括此项,因为在大多数情况下,预计此项已经可用。
设置
将fancybox添加到INSTALLED_APPS:
INSTALLED_APPS+=('fancybox',)
确保有django.template.context_processors.request处理器
TEMPLATES=[{...'OPTIONS':{'context_processors':[...'django.template.context_processors.request',],},},]
只包括fancybox模板
{%include"fancybox/fancybox_css.html"%}{# Before the closing head tag #}{%include"fancybox/fancybox_js.html"%}{# Before the closing body tag #}
在生产服务器上部署时,不要忘记运行:
python manage.py collectstatic
用法
扩展ajax请求的基本模板
{%extendsrequest.is_ajax|yesno:"fancybox/base.html,base.html"%}
将class="fancybox"添加到链接中,并将其设置为要显示的页
<adata-fancyboxdata-type="ajax"href="{%url'remote.html'%}"class="fancybox">Click here</a>
请参阅example应用程序。此应用程序用于手动测试此包的功能。这也是一个很好的例子。
你只需要django 1.4或更高版本就可以运行它。它可能在旧版本上运行,但未经测试。
许可证
django-fancybox是根据bsd许可证发布的。