Added support for Generic Tags. Tags can be applied to Node, Site, Slice, Sliver...
[plstackapi.git] / planetstack / core / models / tag.py
1 import os
2 from django.db import models
3 from core.models import PlCoreBase
4 from django.contrib.contenttypes.models import ContentType
5 from django.contrib.contenttypes import generic
6
7 # Create your models here.
8
9 class Tag(PlCoreBase):
10
11     name = models.SlugField(help_text="The name of this tag", max_length=128)
12     value = models.CharField(help_text="The value of this tag", max_length=1024)
13
14     # The required fields to do a ObjectType lookup, and object_id assignment
15     content_type = models.ForeignKey(ContentType)
16     object_id = models.PositiveIntegerField()
17     content_object = generic.GenericForeignKey('content_type', 'object_id')
18
19     def __unicode__(self):
20         return self.name
21