Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8067937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:29:49+00:00 2026-06-05T12:29:49+00:00

I have created the following TagBase and each category can have subcategory… Will this

  • 0

I have created the following TagBase and each category can have subcategory…
Will this work? How can I override its add function in the TaggableManager?

 class Category(TagBase):
        parent = models.ForeignKey('self', blank=True, null=True,
                                   related_name='child')
        description = models.TextField(blank=True, help_text="Optional")

        class Meta:
            verbose_name = _('Category')
            verbose_name_plural = _('Categories')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:29:50+00:00Added an answer on June 5, 2026 at 12:29 pm

    django-taggit/docs/custom_tagging.txt describes how. You must define an intermediary model with a foreign key tag to your TagBase subclass.

    from django.db import models
    from taggit.managers import TaggableManager
    from taggit.models import ItemBase
    
    # Required to create database table connecting your tags to your model.
    class CategorizedEntity(ItemBase):
        content_object = models.ForeignKey('Entity')
        # A ForeignKey that django-taggit looks at to determine the type of Tag
        # e.g. ItemBase.tag_model()
        tag = models.ForeignKey(Category, related_name="%(app_label)s_%(class)s_items")
    
        # Appears one must copy this class method that appears in both TaggedItemBase and GenericTaggedItemBase
        @classmethod
        def tags_for(cls, model, instance=None):
            if instance is not None:
                return cls.tag_model().objects.filter(**{
                    '%s__content_object' % cls.tag_relname(): instance
                })
            return cls.tag_model().objects.filter(**{
                '%s__content_object__isnull' % cls.tag_relname(): False
            }).distinct()
    
    class Entity(models.Model):
        # ... fields here
    
        tags = TaggableManager(through=CategorizedEntity)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created the following XSLT that will ensure that the field being sent
I have created the following class implementing a ListSelectionListener interface. This class should listen
I have created the following form with qt designer. I added a Add Files
I have created the following accordion in jquery: But I need to add a
I'm using this technique to load data. So I have created the following resolve
I have created the following custom task for Cruise Control .net, but I can't
I have created the following code to show and hide divs. This shows one
I have created the following code http://jsfiddle.net/N65yS/41/ .. My problem is this.. When I
I have created the following public class colModelClass so I can deserialize the colModel
I have created following rule in the .htaccess file located at the root of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.