Giter Club home page Giter Club logo

django-tagging-ng's Introduction

=================
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/

django-tagging-ng's People

Contributors

akaihola avatar clabra avatar flebel avatar gw0 avatar svetlyak40wt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-tagging-ng's Issues

What's the correct way to clear an object's tags?

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!

Caching for get_intersection_by_model()

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.

Compatibility with ordinary django-tagging

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?

IntegrityError exception after Django upgrade

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?

Unclear how to easily add multiple tags to object

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 :(

'Tag' object has no attribute 'name_any'

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'

Exception raised on usage_for_model

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.