Why `update_dict` or `save` of `Collection.models` don't update when I add a new field to `NotetypeDeck`?

I want to achieve the following:

  • generating anki cards from a latex book with a custom note type

For this I created a script calling the python api to facilitate all the needed magic.
I need a custom note type to add examples, theorems, proofs and other stuff to the cards, and since it is math, the latex part also need to be modified.

I want all control at the script and I don’t want to touch the UI for editing, meaning note type has to be managed in the script with the latex changes.

I have this MR to make this changes, and I experienced the following:

  • I can create a new note type (card structure) programmatically, this is the “mathematics-generated” NotetypeDeck
  • I can create a new deck
  • I can modify the note type latextPre part, as you can see from the code
  • I can add new fields to the NotetypeDeck using the Collection.models api, but when I try to save it either by update_dict or the save (deprecated) the new field is not saved (I haven’t checked the Rust side so far if the error is there). The problematic code is here, it is commented out as of now, but the update result says that it updates everything, but when I request it again the newly added field is not there.

Am I doing something wrong here?
What is the good solution here?

Unless I’m missing something, I don’t see you’re adding new fields anywhere in your code. No calls to .new_field() or changes to the flds property

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.