Apparently, you've got two options for managing hierarchical data in django - django-mptt and django-treebeard.
I didn't have any time to test both of them carefully, so I just played a bit with the first one (and with great results!). [p.s. the comparison table above is not mine, but I found it quite useful. Click on the image to find out how it was created... ]
I guess that the key feature I was looking for is the admin-integration. Trees must be displayed and edited properly in the admin... unfortunately both projects don't provide that feature by default, but luckily for there are attempts (#1 and #2) to fix this issue.
In order to use MPTT with your models you just have to download it, add it to your 'installed application' settings and register the models you intend to use:
A mimimal example usage of mptt.register
is given below, where the
model being set up for MPTT is suitable for use with the default
arguments which specify fields and the tree manager attribute::
from django.db import models
import mptt
class Genre(models.Model):
name \= models.CharField(max\_length\=50, unique\=True)
parent \= models.ForeignKey('self', null\=True, blank\=True, related\_name\='children')
mptt.register(Genre, order\_insertion\_by\=\['name'\])
Then, after installing the patches, create a tree-friendly admin by subclassing MpttModelAdmin (check out the docs for more info).
Here's the result - not bad at all! I just had to install django-mptt and the patches needed for using the jquery nested-sortable library with the admin. I'll be working more on this during the next days so probably I'll be posting more stuff....
Cite this blog post:
Comments via Github:
2021
2019
Second biennial conference on Language, Data and Knowledge (LDK 2019), Leipzig, Germany, May 2019.
2017
paper Data integration and disintegration: Managing Springer Nature SciGraph with SHACL and OWL
Industry Track, International Semantic Web Conference (ISWC-17), Vienna, Austria, Oct 2017.
paper Using Linked Open Data to Bootstrap a Knowledge Base of Classical Texts
WHiSe 2017 - 2nd Workshop on Humanities in the Semantic web (colocated with ISWC17), Vienna, Austria, Oct 2017.
paper Fitting Personal Interpretation with the Semantic Web: lessons learned from Pliny
Digital Humanities Quarterly, Jan 2017. Volume 11 Number 1
2016
paper Insights into Nature’s Data Publishing Portal
The Semantic Puzzle (online interview), Apr 2016.
2015
paper Learning how to become a linked data publisher: the nature.com ontologies portal.
5th Workshop on Linked Science 2015, colocated with ISWC 2015., Bethlehem, USA, Sep 2015.
2014
International Semantic Web Conference (ISWC-14), Riva del Garda, Italy, Oct 2014.
2013
New Technologies in Medieval and Renaissance Studies, (forthcoming). (part of the 'Envisioning REED in the Digital Age' collection)
New Perspectives on Medieval Scotland: 1093-1286, Woodbridge, Suffolk: Boydell and Brewer, Studies in Celtic History Series, Aug 2013.
paper Fitting Personal Interpretations with the Semantic Web
Digital Humanities 2013, University of Nebraska–Lincoln, Jul 2013.
2012
2011
paper Browsing highly interconnected humanities databases through multi-result faceted browsers
Digital Humanities 2011 , Stanford, USA, Jun 2011.
2010
LAP LAMBERT Academic Publishing, Aug 2010.
paper Data integration perspectives from the London Theatres Bibliography project
Annual Conference of the Canadian Society for Digital Humanities / Société pour l'étude des médias interactifs (SDH-SEMI 2010), Montreal, Canada, Jun 2010.
blog Django debug toolbar
2009
blog Django signals
blog UML to django
paper Laying the Conceptual Foundations for Data Integration in the Humanities
Proc. of the Digital Humanities Conference (DH09), Maryland, USA, Jun 2009. pp. 211-215
blog Offline django docs
2007
paper PhiloSURFical: browse Wittgensteinʼs Tractatus with the Semantic Web
Wittgenstein and the Philosophy of Information - Proceedings of the 30th International Ludwig Wittgenstein Symposium, Kirchberg, Austria, Aug 2007. pp. 319-335