<commit_before>from django.db import models
from django.utils.translation import ugettext_lazy as _
from taggit.models import Tag


class Category(models.Model):
    """
    A label that can be used to categorize application objects.
    
    Categories differ from tags in that the former are pre-defined at the application level,
    while tags are assigned (and created, if not already existing) on a per-instance basis. 
    """
    name = models.CharField(max_length=128)
    slug = models.SlugField()
    tag_set = models.ManyToManyField(Tag, related_name='category_set')
  
    def __unicode__(self):
        return u'%s' % self.name
    
    class Meta:<commit_msg>Added a custom ``TaggedItem`` model with additional metadata.<commit_after>from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.template.defaultfilters import slugify
from django.contrib.auth.models import User

from taggit.models import Tag, GenericTaggedItemBase, TaggedItemBase

class TaggedItem(GenericTaggedItemBase, TaggedItemBase):
    """
    A intermediate model to record associations between tags and content model instances.
    
    It's a `custom version`_ of ``taggit.models.TaggedItem``, adding a few tagging metadata:
    
    * ``tagger``: the user (an ``auth.User`` instance)  who tagged the item
    * ``tagging_time``: a timestamp specifying when an item was tagged
    
    .. _`custom version`: http://readthedocs.org/docs/django-taggit/en/latest/custom_tagging.html
    """
    tagger = models.ForeignKey(User, null=True, blank=True, editable=False)
    tagging_time = models.DateTimeField(null=True, auto_now_add=True)
    
    class Meta:
        verbose_name = _("tagged item")
        verbose_name_plural = _("tagged items")


class Category(models.Model):
    """
    A label that can be used to categorize application objects.
    
    Categories differ from tags in that the former are pre-defined at the application level,
    while tags are assigned (and created, if not already existing) on a per-instance basis. 
    """
    name = models.CharField(max_length=128)
    slug = models.SlugField()
    tag_set = models.ManyToManyField(Tag, related_name='category_set')
  
    def __unicode__(self):
        return u'%s' % self.name
    
    class Meta:
{'fraction_non_alphanumeric': 0.08648413733159496, 'fraction_numerical': 0.002607561929595828, 'mean_word_length': 3.659919028340081, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '502176', 'n_tokens_mistral': 676, 'n_tokens_neox': 651, 'n_words': 214}