django-zotero is a django app that provides a generic formset to tag any django object with Zotero metadata. Tagged object are easily exportable to Zotero in one click.
First of all, it is needed to have pip installed on your system. It is strongly recommended to install virtualenv and virtualenvwrapper to take the most advantage of pip.
To install pip, go to http://www.pip-installer.org/en/latest/installing.html
To install virtualenv, go to https://pypi.python.org/pypi/virtualenv
To install virtualenvwrapper, go to http://virtualenvwrapper.readthedocs.org/en/latest/install.html#basic-installation
Now install django-zotero:
$ pip install diango-zotero
To use django-zotero, follow the next steps:
Django settings: add the app name to INSTALLED_APPS in settings.py:
INSTALLED_APPS = ( #..., 'zotero', )
Administration side: add the following code to admin.py:
Import the class TagInlineAdmin [1]:
from zotero.admin import TagInlineAdmin
For each model you wish to tag, add to its admin class:
inlines = ( #..., TagInlineAdmin, )
User side: add the following code:
In views.py:
Import the function get_tag_formset [2]:
from zotero.forms import get_tag_formset
In the view that manages the tagged object, instanciate the formset and save it:
tag_formset = get_tag_formset( obj=form.instance, data=request.POST, show_labels=False, labels={ 'item_type': 'Document type', #..., } ) #... tag_formset.save()
In the template that manages the object:
Import the template tag zotero_inline_tags [3]:
{% load zotero_inline_tags from zotero_inline_extras %}
Render the formset:
{% zotero_inline_tags formset %}
In the template that renders the object:
[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:
|