Package: django-multilingual-tags
A reusable Django app that allows you to add translatable tags to any other
model.InstallationTo get the latest stable release from PyPipipinstalldjango-multilingual-tagsTo get the latest commit from GitHubpipinstall-egit+git://github.com/bitmazk/django-multilingual-tags.git#egg=multilingual_tagsAddmultilingual_tagsto yourINSTALLED_APPSINSTALLED_APPS=(...,'multilingual_tags',)Don’t forget to migrate your database./manage.pymigratemultilingual_tagsUsageAdd a generic relation to the model, that you intend to tag.fromdjango.contrib.contenttypesimportgenericfromdjango.dbimportmodelsclassUserProfile(models.Model):# ...# some other model stuff goes here# ...special_attributes=generic.GenericRelation('multilingual_tags.TaggedItem',)Add theTaggingFormMixinto any of your modelforms of a model, you want to
tag and configure the field with the settings dictionary.allowed_tagsconfigures how many tags a user may add. If it’s set to 0 (default), it means,
that the input is not limited.fromdjangoimportformsfrommultilingual_tags.forms.mixinsimportTaggingFormMixinclassUserProfileForm(TaggingFormMixin,forms.ModelForm):tag_field={# ``name`` is the name of the ``GenericRelation`` that was added to# the model'name':'special_attributes','label':_('Special Attributes'),'help_text':_('List any special attributes separated with comma.'),'required':False,'max_tags':0,}The form mixin will automatically adddata-class="multilingual-tags-field"to the form field. This allows you to easily addjquery-typeahead-taggingto your field, which is included in this app.Simply add the static files frommultilingual_tagsto your template.{% load static %}

{# Plain Bootstrap-like styles. #}<linkhref="{% static "multilingual_tags/css/typeahead.tagging.css"%}"rel="stylesheet"media="screen">{# You will also need jquery of course. #}<scriptsrc="{% static "js/libs/jquery-1.9.1.js"%}"></script>{# And then there's typeahead and the tagging plugin. #}<scriptsrc="{% static "multilingual_tags/js/typeahead.bundle.min.js"%}"></script><scriptsrc="{% static "multilingual_tags/js/typeahead.tagging.js"%}"></script>Then you can initialize your tagging field like so:// The source of the tags for autocompletionvartagsource=['Foo','Bar','Anoter Tag','Even more tags','Such autocomplete','Many tags','Wow'];// Turn the input into the tagging input$('[data-class="multilingual-tags-field"]').tagging(tagsource);Et voila! That should really be all there is.Storing the userFor easier access later on, you can store the user, that the tagged item belongs
to on theTaggedItemitself. The form mixin will check if the instance of
theModelFormyou use it with has aget_usermethod for that matter.classMyObject(models.Model):# here goes my model implementationdefget_user(self):"""Here I can return the user I want on the TaggedItem"""returnself.userAdminTo add tags to a model, you have to add theTaggedItemInlineto
that model’s admin. In your own apps, you can just do the following:fromdjango.contribimportadminfrommultilingual_tags.adminimportTaggedItemInlinefrommy_appimportmodelsclassMyModelAdmin(admin.ModelAdmin):inlines=[TaggedItemInline]admin.site.register(models.MyModel,MyModelAdmin)This will render the inline admin form for adding tagged items.If you want to add tags to a third party app, you might need to import its
admin instead of Django’sModelAdminand then unregister and re-register
the model. One way to do it would be this:fromdjango.contribimportadminfrommultilingual_tags.adminimportTaggedItemInlinefromother_app.adminimportSomeModelAdminfromother_app.modelsimportSomeModelclassSomeModelCustomAdmin(SomeModelAdmin):# be careful, if the other admin also defines admins, you need to add# them as wellinlines=SomeModelAdmin.inlines+[TaggedItemInline]admin.site.unregister(SomeModel)admin.site.register(SomeModel,SomeModelCustomAdmin)To get all the tags for an object, you can simply use theTagManager:# Get all tags for a certain model instance>>Tag.objects.get_for_obj(mymodel_instance)[<Tag:mytag>,<Tag:myothertag>]# .. or get all tags for an entire queryset>>Tag.objects.get_for_queryset(MyModel.objects.all())[<Tag:mytag>,<Tag:myothertag>]ContributeIf you want to contribute to this project, please perform the following steps# Fork this repository
# Clone your forkmkvirtualenv-ppython2.7django-multilingual-tagsmakedevelopgitco-bfeature_branchmaster# Implement your feature and testsgitadd.&&gitcommitgitpush-uoriginfeature_branch# Send us a pull request for your feature branch