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 8969689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:37:41+00:00 2026-06-15T17:37:41+00:00

I have a model that is using django-taggit. I want to perform a South

  • 0

I have a model that is using django-taggit. I want to perform a South data migration that adds tags to this model. However, the .tags manager is not available from within a South migration where you have to use the South orm[‘myapp.MyModel’] API instead of the normal Django orm.

Doing something like this will throw an exception because post.tags is None.

post = orm['blog.Post'].objects.latest()
post.tags.add('programming')

Is it possible to create and apply tags with taggit from within a South data migration? If so, how?

  • 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-15T17:37:42+00:00Added an answer on June 15, 2026 at 5:37 pm

    Yes, you can do this, but you need to use Taggit‘s API directly (i.e. create the Tag and TaggedItem), instead of using the add method.

    First, you’ll need to start by freezing taggit into this migration:

    ./manage.py datamigration blog migration_name --freeze taggit
    

    Then your forwards method might look something like this (assuming you have a list of tags you want to apply to all Post objects.

    def forwards(self, orm):
        for post in orm['blog.Post'].objects.all():
            # A list of tags you want to add to all Posts.
            tags = ['tags', 'to', 'add']
    
            for tag_name in tags:
                # Find the any Tag/TaggedItem with ``tag_name``, and associate it
                # to the blog Post
                ct = orm['contenttypes.contenttype'].objects.get(
                    app_label='blog',
                    model='post'
                )
                tag, created = orm['taggit.tag'].objects.get_or_create(
                    name=tag_name)
                tagged_item, created = orm['taggit.taggeditem'].objects.get_or_create(
                    tag=tag,
                    content_type=ct,
                    object_id=post.id  # Associates the Tag with your Post
                )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using django/apache/sqlite3 and I have a django model that looks like this: class
I have a model using Django-MPTT that also has a field for using a
I have a model with an ImageField that I'm indexing for search using Django
I have an object that is tagged using django-taggit . If I wanted to
I'm using Django 1.2.4. I have an admin class for a model that has
Am using django forms on my app. I have a model Client like this:
I have a fairly simple model that uses Django Taggit for tagging. Everything works
I have a model that looks like this and stores data as key-value pairs.
Using Mongoid 2.4.5 on Rails 3.2.1 I have a Model Book that has_many :pages
I am using javascript unobtrusive validation. I have a view model that I am

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.