Anki Forums

importNotes() always adds cards to default deck

I am rewriting my addon for importing mind maps into anki. My class inherits from the Noteimporter class and uses its importNotes() method. Everything works fine already except that no matter what I do, the cards always get added to the default deck (did = 1). I already call col.decks.select() to select the preferred deck and I also tried adding the did to the ForeignNotes which are used as input for importNotes() but for some reason the notes still get imported to the default deck every time.col.decks.selected() does return the preferred did in the moment the cards are created (in after_note_updates()).

Does anyone know what else I can do to set the deck that I want to import my cards to?

This is covered in https://addon-docs.ankiweb.net/#/getting-started?id=the-collection

1 Like

Thank you for the link! I added the code from the guide to my importer but sadly it did not change anything. The cards are still imported to the default deck.

I temporarily solved the problem by manually moving all imported cards to the desired deck afterwards but I would still be very interested in finding the cause.

1 Like

I’ve updated the code there to add a .save() call that may have been required - please try it again.

1 Like

Thank you very much! This was the solution :slight_smile: