django工具,用于标记对象并将其导出到zotero
django-zotero的Python项目详细描述
django-zotero是一个django应用程序,它提供一个通用表单集,用Zotero元数据标记任何django对象。标记的对象很容易在一次单击中导出到Zotero。
安装
首先,需要在系统上安装pip强烈建议安装virtualenv和virtualenvwrapper以充分利用pip。
要安装pip,请转到http://www.pip-installer.org/en/latest/installing.html
要安装virtualenv,请转到https://pypi.python.org/pypi/virtualenv
要安装virtualenvwrapper,请转到http://virtualenvwrapper.readthedocs.org/en/latest/install.html#basic-installation
现在安装django-zotero:
$ pip install django-zotero
用法
要使用django-zotero,请执行以下步骤:
django设置:将应用程序名称添加到设置中已安装的应用程序。py:
INSTALLED_APPS = ( #..., 'zotero', )
管理端:将以下代码添加到admin.py:
导入类TagInlineAdmin[1]:
from zotero.admin import TagInlineAdmin
对于要标记的每个模型,添加到其管理类:
inlines = ( #..., TagInlineAdmin, )
用户端:添加以下代码:
在视图中.py:
导入函数get_tag_formset[2]:
from zotero.forms import get_tag_formset
在管理标记对象的视图中,实例化表单集并保存它:
tag_formset = get_tag_formset( obj=form.instance, data=request.POST, show_labels=False, labels={ 'item_type': 'Document type', #..., } ) #... tag_formset.save()
在管理对象的模板中:
导入模板标记zotero_inline_tags[3]:
{% load zotero_inline_tags from zotero_inline_extras %}
呈现表单集:
{% zotero_inline_tags formset %}
在呈现对象的模板中:
[1] | TagInlineAdmin is an inline class ready to be added as inline of other admin class. |
[2] | get_tag_formset is a function that gets the formset with Zotero tags for an object. It is based on a generic formset factory and takes four arguments:
|
[3] | zotero_inline_tags is a template tag that renders a formset. It takes one argument: the formset it renders. |
[4] | zotero_tags is a template tag that renders the HTML code of Zotero metadata. It takes three arguments:
|