Bookmarks functionality goes away with custom menu

Issue #28 resolved
Mark Cahill
created an issue

When using a custom menu, bookmarks functionality goes away. I tried adding



self.children.append(BookmarkMenuItem()) }}}

to the, but was only able to show existing bookmarks. There is no star to create or remove bookmarks.

Comments (12)

  1. Mark Cahill reporter

    Python 2.6.5, Django 1.1.1, and development django-admin-tools. To repeat, simply run the admin command to create a new custom menu. The necessary code to create the bookmarks functionality is not included.

  2. David Jean Louis repo owner

    Hm, you are describing a different problem here: "the bookmark item is not included in the default custom".

    But if you added "self.children.append(BookmarkMenuItem())" the bookmark functionality should work as expected, right ?

    Also, the management commands are currently broken (I have a "template not found" error, this will be fixed soon) which makes me wonder what version you actually use ?

  3. Mark Cahill reporter

    I was able to get the management commands working by making the following change:

    In menu/management/commands/ on line 18:

            open(dst, 'w').write(render_to_string('admin_tools/menu/menu.txt', {

    after appending the BookmarkMenuItem, I get a bookmarks menu, but no star appears. No bookmarks can be added or removed.

  4. David Jean Louis repo owner

    after appending the BookmarkMenuItem, I get a bookmarks menu, but no star appears.

    No bookmarks can be added or removed.

    Hmm, I cannot reproduce this problem :( It works for me.

    It would be great if you could look at this and come with a patch.


    -- David

  5. Mark Cahill reporter

    Maybe. Can you point me at the code in the core that handles the generation of that star (add/remove functionality)? Is it supposed to show up when the bookmarks menu is added?

  6. David Jean Louis repo owner


    The star should show up as long as the menu contains a BookmarkMenuItem (now renamed items.Bookmarks), the relevant code is in:


    line 32.

  7. Mark Cahill reporter

    My menu (menu.children) looks like this: [< object at 0x01689430>, < object at 0x01689E90>, < object at 0x01689E10>, < object at 0x01689C10>, < object at 0x01689DB0>, < object at 0x01689970>, < object at 0x016896D0>]

    However, when I run that loop against it (c for c in menu.children if isinstance(c, BookmarkMenuItem)), I get an empty list. So somehow this line of code is not picking up custom instances somehow.

    If I change line 31 to the following, it works:

    if len([c for c in menu.children if type(c).__name__ == 'BookmarkMenuItem']) > 0:

    Now obviously this isn't a realistic or desirable solution, but it should help you narrow down why it's not working. I'm not familiar with isinstance and the caveats thereof. Is there a way to ensure that objects are recognized as instances of that class?

  8. David Jean Louis repo owner

    Oh ! well then it's normal. You seem to have modified the admin_tools namespace somehow, so : !=

    Just import admin_tools without no parent namespace, and everything should work again.


    -- David

  9. Mark Cahill reporter

    OK. I see. I had admin_tools installed within my application directory, so it was being imported within that namespace. I moved the admin_tools directory to my python path, and the star appeared. Thanks for helping me figure that out. At least this is documented for anyone else who runs into that problem.

  10. Log in to comment