0

我从这里尝试简单的示例http://www.feinheit.ch/media/labs/feincms/admin.html '

模型.py:

class Locations(MPTTModel):
    title = models.CharField(max_length=100)
    parent = TreeForeignKey('self', null=True, blank=True, related_name='children')

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['tree_id', 'lft']

管理员.py:

class LocationsAdmin(tree_editor.TreeEditor):
    pass

admin.site.register(Locations, LocationsAdmin)

但是我在管理界面中的模型我只能移动,不能剪切,或者创建子。如下图所示:http ://www.feinheit.ch/media/labs/feincms/_images/tree_editor.png 。怎么做对?

4

1 回答 1

0

对于“添加孩子”需要这样的东西:

class LocationsAdmin(TreeEditor):
    def _actions_column(self, instance):
        action = ['<div class="drag_handle"></div>',]
        action.append(u'<a href="add/?parent=%(id)s"><img src="%(static)sadmin/img/icon_addlink.gif"></a>'
                      % {'id': instance.id, 'static': django_settings.STATIC_URL})

        return action
于 2013-09-20T19:13:59.363 回答