This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Extensible tags in Django.

Tags can be associated with any django model. You can add as many key-value pairs to the tags as you wish.

TagManager

The best way to use django-kvtags is through TagManager. First, add TagManager to your model to which you will add tags:

class YourModel(models.Model):
    # your stuff
    objects = models.Manager()
    tags = TagManager()

If you want django-kvtags to use cache when it’s possible, pass the cache name with cache parameter to TagManager:

class YourModel(models.Model):
    # your stuff
    objects = models.Manager()
    tags = TagManager(cache='default')

add (obj, **kwargs)

Adds tags matched by kwargs to obj.

add_by_kv (obj, **kwargs)

Adds tags whose key-values are matched by kwargs to obj.

remove (obj, **kwargs)

Removes tags matched by kwargs from obj.

remove_by_kv (obj, **kwargs)

Removes tags whose key-values are matched by kwargs from obj.

filter (obj, **kwargs)

Returns QuerySet of Tags bound to obj and matched by kwargs.

get_list (obj)

Returns a list of Tag model instances bound to obj

get_id_list (obj)

Returns a list of IDs of Tags bound to obj

get_digest_list (self, obj)

Returns a list of objects which contains digested data of Tags bound to obj. If cache is available and set, this method stores tag and item-tag dictionaries in the cache in order to make a lot less SQL queries.

Using API

django-kvtags supports tastypie.

TagResource

# urls.py
from kvtags.api import TagResource

tag_resource = TagResource()

urlpatterns = patterns('',
    # The normal jazz here...
    (r'^api/', include(tag_resource.urls)),
)

or

# urls.py
from tastypie.api import Api
from kvtags.api import TagResource

your_api = Api(api_name='v1')
# Your other resources
your_api.register(TagResource())


urlpatterns = patterns('',
    # The normal jazz here...
    (r'^api/', include(your_api.urls)),
)

TaggedItemResource

TaggedItem has generic relation to your models. If you don’t need to resolve the relations, you can include TaggedItemResource to your API just as you include TagResource.

However, if you want to resolve generic relations, you should create a new class based on TaggedItemResource by yourself. Then, add the new class to the API as usual.

Example:

# urls.py
from kvtags.api import TaggedItemResource
from tastypie.contrib.contenttypes.fields import GenericForeignKeyField
from yourapp.models import Spam, Egg
from yourapp.api import SpamResource, EggResource

class MyTaggedItemResource(TaggedItemResource):
    content_object = GenericForeignKeyField({
        Spam: SpamResource,
        Egg: EggResource
    }, 'content_object')

Adding Tags Field to a Resource

If you want to add the tags associated with a model to the model’s resource, you can do that by using get_list or get_digest_list methods as follow:

class YourModelResource(ModelResource):
    # your stuff
    tags = fields.ListField()

    def dehydrate_tags(self, bundle):
        return YourModel.tags.get_digest_list(bundle.obj)
Release History

Release History

1.5.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.4.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.4.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-kvtags-1.5.1.tar.gz (7.0 kB) Copy SHA256 Checksum SHA256 Source Oct 9, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting