Django MPTT Admin

223 views
Skip to first unread message

Matthias Kestenholz

unread,
Feb 26, 2009, 4:42:15 AM2/26/09
to django...@googlegroups.com
Hey,

A topic which comes up on this list from time to time is an automatic
admin interface for django-mptt. I'd like to advertise a piece of code
we have written at our company a little bit, and I'd also like to invite
everyone to give comments and feedbacks. I do have many more ideas
floating around, and there are a couple of issues still open, but I think
the code is ready for wider review and maybe usage, who knows?


The current version of the code generates an interface with drag/drop
capabilities for managing mptt-based trees. It's still very clear that the
code was extracted from a `classical' page cms. All you need to do
is the following:


-- 8< --

from django.db import models

class Category(models.Model):
title = models.CharField(max_length=200)
parent = models.ForeignKey('self', related_name='children',
blank=True, null=True)

-- 8< --

from django.contrib import admin
from feincms.admin import editor

class CategoryAdmin(editor.TreeEditorMixin, admin.ModelAdmin):
pass

admin.site.register(Category, CategoryAdmin)

-- 8< --

The generated admin interface looks like that:

http://spinlock.ch/pub/feincms/category_tree_admin.png

The page cms feeling is still very much there, but we'll see.

In any case, you'll find the code on github:
http://github.com/matthiask/feincms/tree/master


Thanks,
Matthias


--
"Programming is an art form, like the creation
of poetry or music." (Donald E. Knuth, 1974)

Antoni Aloy

unread,
Feb 26, 2009, 2:54:38 PM2/26/09
to django...@googlegroups.com
2009/2/26 Matthias Kestenholz <matthias....@gmail.com>:

It seems very nice. I'm going to give it a try. :)

Thank you!

--
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

Neeraj Sharma

unread,
Nov 11, 2014, 6:38:08 AM11/11/14
to django...@googlegroups.com, matthias....@gmail.com
How to use Django Mttp Admin as an Inline in admin.py ?
Message has been deleted

Neeraj Sharma

unread,
Nov 11, 2014, 8:21:44 AM11/11/14
to django...@googlegroups.com, matthias....@gmail.com
Thanx for your quick response Matthias Kestenholz, but i actually i want to use MPTT Admin as an inline form, code you have written will work as a normal admin form


On Thursday, 26 February 2009 15:12:15 UTC+5:30, Matthias Kestenholz wrote:
Reply all
Reply to author
Forward
0 new messages