0

I try simple exsample from here http://www.feinheit.ch/media/labs/feincms/admin.html'

models.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']

admin.py:

class LocationsAdmin(tree_editor.TreeEditor):
    pass

admin.site.register(Locations, LocationsAdmin)

But my model in the admin interface I can only move, but not cut, or create child. Like shown in the screenshot below: http://www.feinheit.ch/media/labs/feincms/_images/tree_editor.png. How do it right?

Atterratio
  • 445
  • 2
  • 9
  • 25

1 Answers1

0

For "add child" need something like this:

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
Atterratio
  • 445
  • 2
  • 9
  • 25