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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:37:42+00:00 2026-05-28T20:37:42+00:00

I am trying to use Django to create a recursive relationship, which gives users

  • 0

I am trying to use Django to create a recursive relationship, which gives users a folder-like hierarchical structure in which to place resources.

What would be the best way to achieve this?

I know I could use treebeard or mptt to create a nested set but I have read that making changes to the tree structure (something that would be happening a lot in this case) can be quite an intensive operation as a lot of fields have to be updated.

On the other hand, I could folder model with a ForeignKey to self but how do I manage the top level folders with no foreign key value? Will Django complain if I just set this value to be NULL?

Any advice appreciated.

Thanks.

  • 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-28T20:37:43+00:00Added an answer on May 28, 2026 at 8:37 pm

    Treebeard actually supports three different tree implementations, just choose the one that will suite your needs.

    • Adjacency List (fast writes at the cost of slow reads)
    • Materialized Path (probably the fastest way of working with trees in SQL)
    • Nested Sets (very efficient reads at the cost of high maintenance on write/delete operations)

    Docs are here: https://tabo.pe/projects/django-treebeard/docs/tip/

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

Sidebar

Related Questions

I am trying to use django-socialauth ( http://github.com/uswaretech/Django-Socialauth ) for authenticating users for my
I'm trying to use django-ajax-related-fields, and the foreignkey field I'm trying to create a
I am trying to use django-tables to create a sortable table out of some
Trying to make a django test application which will use stored oracle's procedures to
I have a small app I'm working on where I'm trying to use Django's
I'm trying to use the Django ORM in some standalone screen scraping scripts. I
I am trying to use the django send_mail method. I am running into 2
I'm building a Django site and trying to use the request.is_ajax() function... But it's
I'm developing a Django app, and I'm trying to use Python's logging module for
I'm trying to modify a Django form to use a textarea instead of a

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.