svetlyak40wt / django-tagging-ng Goto Github PK
View Code? Open in Web Editor NEWDjango tagging with multilingual, synonyms and hierarchy!
Home Page: http://code.google.com/p/django-tagging/
License: Other
Django tagging with multilingual, synonyms and hierarchy!
Home Page: http://code.google.com/p/django-tagging/
License: Other
================= Django Tagging NG ================= This is a enhanced tagging application for Django projects - For installation instructions, see the file "INSTALL.txt" in this directory - For detailed instructions on how to configure and know all possibilities of this application, see the file "OVERVIEW.txt" Rquirements ----------- Note that this application requires Python 2.3 or later, and Django 0.96 or later. You can obtain Python from http://www.python.org/ and Django from http://www.djangoproject.com/. Quickstart ---------- 1.- Register a model: from django.db import models import tagging from shop.apps.products.models import Widget class Widget(models.Model): name = models.CharField(max_length=50) tagging.register(Widget) 2.- Use it w = Widget.objects.get(...) from tagging.models import Tag, TaggedItem house_tag = Tag.objects.get(name='house') thing_tag = Tag.objects.get(name='thing') - Set tags for instance: w.tags = 'tag1 tag2' - Get tag for instance: w.tags [<Tag: tag1>, <Tag: tag2>] - Retrive instances with tag1 AND tag2 TaggedItem.objects.get_by_model(Widget, [house_tag, thing_tag]) [<Widget: pk=1>] - Retrieve filtered instances with 'tag1' TaggedItem.objects.get_by_model(Widget.objects.filter(price__lt=50), 'house') - Get all tags for a model: Widget.tags.all() [<Tag: tag1>, <Tag: tag2>>] - Get tags for a model with usage counts: Widget.tags.count() - Get related tags (retrieve tags used by model instances which are also tagged with tag1 and tag2) Widget.tags.related('tag1', min_count=1) [<Tag: tag2>] Widget.tags.related(['tag1', 'tag2'], min_count=1) [] Authors ------- This application is based on the original code, written by: Jonathan Buchanan <[email protected]> Enhanced by: Alexander Artemenko <[email protected]> Antti Kaihola <[email protected]> GW [http://gw.tnode.com/] <[email protected]> Concha Labra https://github.com/clabra Sources ------- Django-tagging-ng: http://github.com/svetlyak40wt/django-tagging-ng/ Django-tagging: http://code.google.com/p/django-tagging/
See http://github.com/svetlyak40wt/django-tagging-ng/commit/39473cd2769cc82f0d569854113b0d4d27d543f0#commitcomment-96776 .
It seems that commit broke tagging-ng for non-MULTILINGUAL sites - but I must be wrong.
-- Paul
I can achieve this by doing something like:
o.tags = ''
del o.tags
o.tags = []
but not without causing an exception:
AttributeError: 'Tag' object has no attribute 'name_any'
so basically I can proceed by doing one of those and squelching that exception, but I'd rather do it the 'correct' way that doesn't cause an exception!
Plugin is showing in https://www.djangopackages.com/grids/g/tagging/ as having these features but I can't see them mentioned in docs. Are they implemented?. If so it would be nice to have some examples of use. Thanks
The method fetches all pk's (which can be a lot), then limits queryset on pk__in = pks. Either provide a method which allows fetching raw pks (best solution) or store them in a cache if settings.TAGGING_CACHE is set. Packed list of int's consumes very little memory in the cache.
This is not really an issue, this is a question: can I use tagging-ng instead of tagging, so that apps which work with tagging could work with tagging-ng? Are there any known compatibility issues?
Was installing it according to the docs, but "import tagging" fails because it wants DJANGO_SETTINGS_MODULE defined properly. It's not hard to work around, but since I'm a django newbie, I was slightly confused ;)
I'm getting next exception:
IntegrityError: (1048, "Column 'object_id' cannot be null")
when trying to save instance for a model with a tags=TagField() field
I think this exception has beginning to be thrown after a Django upgrade to v 1.5.2
¿It's possible django-tagging-ng is not Django 1.5.2 compatible?
I'm playing with django-tagging-ng and I've written a view function to add new tags to an object
def add(request):
if request.method == 'POST':
form = TagForm(request.POST)
if form.is_valid():
model = models.get_model(request.GET.get('app_label'), request.GET.get('object_name'))
record = model.objects.get(id=request.GET.get('id', None))
tags = form.cleaned_data['tags']
Tag.objects.add_tag(record, tags)
referer = request.META.get('HTTP_REFERER', '/')
return HttpResponseRedirect(referer)
This is supposed to add a tag to an object. It works fine in the case that form.cleaned_data['tags'] contains a single tag.
I've also succeeded in adding multiple tags by iterating over parse_tag_input(form.cleaned_data['tags']) and adding a single tag in each iteration
BUT.. When the tag input is like '''one two "three four"''' I fail because parse_tag_input is treating "three four" as a single tag.
Inside add_tag it fails if a tag has multiple elements.
What is the most convenient way to append tags to a list of existing tags for an object and to handle inputs like ''' one two "three four"'''
Sorry if this isn't clear - it actually makes no sense as I read it back to myself :(
Creating a new Tag object via Tag.objects.create(name='ABC')
or via django admin doesn't coerce the name to lowercase. The setting only seems to affect tags created via obj.tags = 'XyZ'
.
I'm experiencing this exception a lot when trying to update the tags of an object o
whose o.tags
is non-empty (see below). I realised that in my version (0.3.3, from pip), nothing seems to define what name_any
should be. Same when I git cloned the HEAD from here (github). I think this must be a bug is it?
In [129]: v.tags
Out[129]: []
In [130]: v.tags = '"tag 1", tag2'
In [132]: v.tags
Out[132]: [<Tag: tag 1>, <Tag: tag2>]
In [133]: v.tags = 'tag3'
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/virtualenvs/nhschoices/local/lib/python2.7/site-packages/django/core/management/commands/shell.pyc in <module>()
----> 1 v.tags = 'tag3'
/virtualenvs/nhschoices/local/lib/python2.7/site-packages/tagging/managers.pyc in __set__(self, instance, value)
63
64 def __set__(self, instance, value):
---> 65 Tag.objects.update_tags(instance, value)
66
67 def __delete__(self, instance):
/virtualenvs/nhschoices/local/lib/python2.7/site-packages/tagging/models.pyc in update_tags(self, obj, tag_names)
54 tag__in=tags_for_removal).delete()
55 # Add new tags
---> 56 current_tag_names = [tag.name_any for tag in current_tags]
57 for tag_name in updated_tag_names:
58 if tag_name not in current_tag_names:
AttributeError: 'Tag' object has no attribute 'name_any'
So I have a view that displays all posts tagged with a given tag. The url looks like example.com/tag/mytag . The problem is, is the tag is "my tag" I get an error that it can't properly reverse the url when I have {% url tag "my tag" %}. Any thoughts?
In [20]: Tag.objects.usage_for_model(Stream)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/lacrymology/workspace/django/groupsolo/radiopirate/<ipython-input-20-72f5e29df210> in <module>()
----> 1 Tag.objects.usage_for_model(Stream)
/home/lacrymology/workspace/django/groupsolo/radiopirate/src/django-tagging/tagging/models.pyc in usage_for_model(self, model, counts, min_count, filters)
156 for f in filters.items():
157 queryset.query.add_filter(f)
--> 158 usage = self.usage_for_queryset(queryset, counts, min_count)
159
160 return usage
/home/lacrymology/workspace/django/groupsolo/radiopirate/src/django-tagging/tagging/models.pyc in usage_for_queryset(self, queryset, counts, min_count)
174 """
175
--> 176 extra_joins = ' '.join(queryset.query.get_from_clause()[0][1:])
177 where, params = queryset.query.where.as_sql()
178 if where:
AttributeError: 'Query' object has no attribute 'get_from_clause'
It's hard to read the docs. Maybe a good idea to use https://readthedocs.org/ and insert a link in README.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.