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

  • Home
  • SEARCH
  • 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 6748131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:44+00:00 2026-05-26T12:31:44+00:00

I am building an application using django, and using django-south for the database schema

  • 0

I am building an application using django, and using django-south for the database schema migrations. I’m using django-mptt to build a comment system, and I installed 0.5-pre (the current git master branch).

The version I’m using has a django-field called TreeForeignKey, but I’m trying to test whether or not 0.5 has a bug that exists in 0.4, so I removed my version of django-mptt and installed the current release from the cheeseshop. I modified my code to use ForeignKey rather than TreeForeignKey.

When it comes time to do migrations, it obviously breaks with this message:

ValueError: Cannot import the required field 'mptt.fields.TreeForeignKey'

All my migration files reference mptt.fields.TreeForeignKey, which doesn’t exist in django-mptt 0.4.

My Comment model in django-mptt 0.5:

from mptt.models import MPTTModel
from mptt.fields import TreeForeignKey

class Comment(MPTTModel):
    # ...
    parent = TreeForeignKey('self', related_name='children', blank=True, null=True)

The same model after I downgrade to django-mptt 0.4

import django.db.models
from mptt.models import MPTTModel

class Comment(MPTTModel):
    # ... cruft
    # TreeForeignKey does not exist in mptt 0.5!
    parent = models.ForeignKey('self', related_name='children', blank=True, null=True) 

There are two rather hacky approaches I came up with to fix this and allow the migration to work:

  1. Add the TreeForeignKey class to my django-mptt install.
  2. Modify my migration files to remove references to mptt.fields.TreeForeignKey.

I took the first approach and it worked, but I feel it’s kind of a hack (but not as much as the second option).

Is there a non-hacky way to do what I did with downgrading dependencies that resulted in some fields changing in my models?

  • 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-05-26T12:31:44+00:00Added an answer on May 26, 2026 at 12:31 pm

    This really has nothing to do with South. the fields module of django-mptt didn’t exist before 0.5.pre. So when you downgraded to 0.4, you’re now rightly getting an ImportError.

    I can’t tell you what the proper import to use is because I’m not running 0.4 and for some crazy reason the developers did not maintain the 0.4 docs. However, your second approach seems most appropriate. There shouldn’t be any reason you need to actually use TreeForeignKey in migration. It’s simply a wrapper around a standard ForeignKey.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a database application using django. Much of the data recorded requires supporting
I am building a high school team application using Django. Here is my working
I am working on building a web-application using Django. Since I'm new to working
I'm building a per-user file browsing/uploading application using Django and when I run this
I am building an application in django, that is already using a lot of
I'm building an application that communicates with a django backend using json-rpc. So far
I am building a Django application that will be using UTC for all time
Unlike this question: Linker Error while building application using Boost Asio in Visual Studio
I am currently building an application using ASP.NET MVC. The data entry pages are
I'm building an application using the Supervising Controller pattern (Model View Presenter) and I

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.