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?
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.
Hi, last year I used this solution for one of my anki add-on and it solved my problem too, but since version 2.1.45 this does not work anymore. I’m not sure what changes were made to anki. When I check the database for the new anki versions all new cards are assigned “did” = 1, which is the default deck. Below is the current code.
did = mw.col.decks.id(deck)
mw.col.decks.select(did)
model = mw.col.models.byName(modelName)
if not model:
model = mw.col.models.new(modelName)
mw.col.models.add(model)
template = mw.col.models.newTemplate("Default")
mw.col.models.addTemplate(model, template)
deck = mw.col.decks.get(did)
deck['mid'] = model['id']
mw.col.decks.save(deck)
model['did'] = did
mw.col.models.save(model)
...
...
..