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