python-drafthorse icon indicating copy to clipboard operation
python-drafthorse copied to clipboard

README example does not work

Open hannob opened this issue 2 months ago • 1 comments

Trying to run the example code from the README file I get:

Traceback (most recent call last):
  File "/tmp/dh/./dh", line 26, in <module>
    note.content.add("Test Node 1")
    ^^^^^^^^^^^^^^^^
AttributeError: 'StringElement' object has no attribute 'add'

I believe a similar change to this needs to be applied: https://github.com/pretix/python-drafthorse/commit/b2d839f996a6ff00491a41384130a72c95d24118

hannob avatar Oct 08 '25 11:10 hannob

You are right, the example was not updated after Note model change #69. To make it work, you can use:

doc.header.notes.add(IncludedNote(content="Test Node 1"))

instead of

note = IncludedNote()
note.content.add("Test Node 1")
doc.header.notes.add(note)

I've created the pull request #89 to update the example on the README

kuhntob avatar Oct 09 '25 14:10 kuhntob