跳转到主要内容

Django的简单Fancybox模态框

项目描述

这是一个Django集成Fancybox

https://img.shields.io/pypi/v/django-fancybox.svg https://img.shields.io/pypi/dm/django-fancybox.svg https://img.shields.io/github/license/bashu/django-fancybox.svg

安装

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请求的基本模板

{% extends request.is_ajax|yesno:"fancybox/base.html,base.html" %}

class="fancybox" 添加到链接,并将href设置为要显示的页面

<a data-fancybox data-type="ajax" href="{% url 'remote.html' %}" class="fancybox">Click here</a>

请参阅 example 应用程序。该应用程序用于手动测试此包的功能。它也是一个很好的例子。

您只需要Django 1.4或更高版本即可运行它。它可能在旧版本上运行,但没有经过测试。

许可证

django-fancybox 根据BSD许可证发布。

项目细节


下载文件

下载适合您平台的文件。如果您不确定选择哪一个,请了解更多关于安装包的信息。

源代码分发

django-fancybox-0.1.6.tar.gz (30.0 kB 查看哈希值)

上传时间 源代码

构建分发

django_fancybox-0.1.6-py2.py3-none-any.whl (30.2 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下支持