from django.db import models

from taggit.managers import TaggableManager
from taggit.models import TaggedItemBase

class Food(models.Model):
    name = models.CharField(max_length=50)
    
    tags = TaggableManager()
    
    def __unicode__(self):
        return self.name

class Pet(models.Model):
    name = models.CharField(max_length=50)
    
    tags = TaggableManager()
    
    def __unicode__(self):
        return self.name


class HousePet(Pet):
    trained = models.BooleanField()

# test direct-tagging with custom through model
    
class TaggedFood(TaggedItemBase):
    content_object = models.ForeignKey('DirectFood')
    
class DirectFood(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager(through=TaggedFood)

class TaggedPet(TaggedItemBase):
    content_object = models.ForeignKey('DirectPet')
    
class DirectPet(models.Model):
    name = models.CharField(max_length=50)

    tags = TaggableManager(through=TaggedPet)
    
    def __unicode__(self):
        return self.name
    

class DirectHousePet(DirectPet):
    trained = models.BooleanField()

# test custom through model to model with custom PK

class TaggedCustomPKFood(TaggedItemBase):
    content_object = models.ForeignKey('CustomPKFood')

class CustomPKFood(models.Model):
    name = models.CharField(max_length=50, primary_key=True)

    tags = TaggableManager(through=TaggedCustomPKFood)
    
    def __unicode__(self):
        return self.name
    
class TaggedCustomPKPet(TaggedItemBase):
    content_object = models.ForeignKey('CustomPKPet')
    
class CustomPKPet(models.Model):
    name = models.CharField(max_length=50, primary_key=True)

    tags = TaggableManager(through=TaggedCustomPKPet)
    
    def __unicode__(self):
        return self.name

class CustomPKHousePet(CustomPKPet):
    trained = models.BooleanField()

@@ -109,16 +109,17 @@
 emBase%0A%0A
+%0A
 class Fo
@@ -431,17 +431,16 @@
 f.name%0A%0A
-%0A
 class Ho
@@ -485,27 +485,28 @@
 eanField()%0A%0A
+%0A
 # 
-t
+T
 est direct-t
@@ -538,20 +538,16 @@
 h model%0A
-    
 %0Aclass T
@@ -626,20 +626,102 @@
 tFood')%0A
-    
+%0Aclass TaggedPet(TaggedItemBase):%0A    content_object = models.ForeignKey('DirectPet')%0A
 %0Aclass D
@@ -841,98 +841,8 @@
 d)%0A%0A
-class TaggedPet(TaggedItemBase):%0A    content_object = models.ForeignKey('DirectPet')%0A    %0A
 clas
@@ -1014,21 +1014,16 @@
 elf.name
-%0A    
 %0A%0Aclass 
@@ -1090,11 +1090,12 @@
 ()%0A%0A
+%0A
 # 
-t
+T
 est 
@@ -1234,24 +1234,120 @@
 omPKFood')%0A%0A
+class TaggedCustomPKPet(TaggedItemBase):%0A    content_object = models.ForeignKey('CustomPKPet')%0A%0A
 class Custom
@@ -1546,112 +1546,8 @@
 ame%0A
-    %0Aclass TaggedCustomPKPet(TaggedItemBase):%0A    content_object = models.ForeignKey('CustomPKPet')%0A    
 %0Acla

Reorder things for easier readability