django工具,用于标记对象并将其导出到zotero

django-zotero的Python项目详细描述


django-zotero是一个django应用程序,它提供一个通用表单集,用Zotero元数据标记任何django对象。标记的对象很容易在一次单击中导出到Zotero

安装

首先,需要在系统上安装pip强烈建议安装virtualenvvirtualenvwrapper以充分利用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,请执行以下步骤:

  1. django设置:将应用程序名称添加到设置中已安装的应用程序。py:

    INSTALLED_APPS = (
        #...,
        'zotero',
    )
    
  2. 管理端:将以下代码添加到admin.py:

    1. 导入类TagInlineAdmin[1]

      from zotero.admin import TagInlineAdmin
      
    2. 对于要标记的每个模型,添加到其管理类:

      inlines = (
          #...,
          TagInlineAdmin,
      )
      
  3. 用户端:添加以下代码:

    1. 在视图中.py:

      1. 导入函数get_tag_formset[2]

        from zotero.forms import get_tag_formset
        
      2. 在管理标记对象的视图中,实例化表单集并保存它:

        tag_formset = get_tag_formset(
            obj=form.instance,
            data=request.POST,
            show_labels=False,
            labels={
                'item_type': 'Document type',
                #...,
            }
        )
        #...
        tag_formset.save()
        
    2. 在管理对象的模板中:

      1. 导入模板标记zotero_inline_tags[3]

        {% load zotero_inline_tags from zotero_inline_extras %}
        
      2. 呈现表单集:

        {% zotero_inline_tags formset %}
        
    3. 在呈现对象的模板中:

      1. 导入模板标记zotero_tags[4]

        {% load zotero_tags from zotero_tags_extras %}
        
      2. 呈现Zotero元数据:

        {% zotero_tags
            object=document
            vocabulary="dc"
            output_method="meta" %}
        
[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:

  1. obj: object to tag
  2. data: data to instanciate the content of the formset
  3. show_labels: if true, show the labels as headers on the top of the formset; if false, show the labels as placeholders
  4. labels: set alternative labels - default labels are ‘item_type’, ‘field’ and ‘value’
[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:

  1. object: tagged object
  2. vocabulary: the vocabulary to code the metadata - currently it works with Dublin Core (“dc”)
  3. output_method: the method to code the metadata - currently it works HTML <meta> tags (“meta”)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java找到最低年龄并从文件中打印出数组中相应的名称?   调用save后,从加密pdf加载的java PDDocument将转换为加密文档   如何在Java中为showInputDialog中的输入添加限制   java如何将randomHuman构造函数扩展为两种类型的对象?   java Spring security db UserDetails服务不考虑用户的角色   java是否隐式同步了Android线程方法?   用烟尘+桨进行java大程序分析   Java8流:在流中使用if/else条件   tls1。2当Rserve启用TLS时,Java Rconnection挂起   java如何在intellij上配置代码格式化程序   Java如何使“静态”变量名变为动态   java如何在Netbeans项目中从jar中排除源程序包   安卓如何在中使用@string/xyz。java文件?   使用PDFBOX2.0从PDF中提取java文本   在IntelliJ IDEA中运行Gradle测试时,java“找不到给定包含的测试”