如何在Django中显示每条Evernote笔记的内容

How to show the content of each Evernote note in Django

https://github.com/evernote/evernote-sdk-python/blob/master/sample/django/evernote_oauth_sample/templates/oauth/callback.html

https://github.com/evernote/evernote-sdk-python/blob/master/sample/django/oauth/views.py

显示第一个笔记(作品)的内容:

// views.py(我的叉子)

updated_filter = NoteFilter(order=NoteSortOrder.UPDATED)
updated_filter.notebookGuid = notebooks[0].guid
offset = 0
max_notes = 1000
result_spec = NotesMetadataResultSpec(includeTitle=True)
result_list = note_store.findNotesMetadata(auth_token, updated_filter, offset, max_notes, result_spec)

note_guid = result_list.notes[0].guid
content = note_store.getNoteContent(auth_token, note_store.getNote(note_guid, True, False, False, False).guid)
return render_to_response('oauth/callback.html', {'notebooks': notebooks, 'result_list': result_list, 'content': content})

// oauth/callback.html(我的叉子)

<ul>
  {% for note in result_list.notes %}
    <li><b>{{ note.title }}</b><br>{{ content }}</li>
  {% endfor %}

如何在Django中显示每条笔记的内容?(这是一次不成功的尝试)

updated_filter = NoteFilter(order=NoteSortOrder.UPDATED)
    updated_filter.notebookGuid = notebooks[0].guid
    offset = 0
    max_notes = 1000
    result_spec = NotesMetadataResultSpec(includeTitle=True)
    result_list = note_store.findNotesMetadata(auth_token, updated_filter, offset, max_notes, result_spec)

    contents = []
    for note in result_list.notes:
        content = note_store.getNoteContent(auth_token, note_store.getNote(note.guid, True, False, False, False).guid)
        contents.append(content)

return render_to_response('oauth/callback.html', {'notebooks': notebooks, 'result_list': result_list, 'contents': contents})

<ul>
  {% for note in result_list.notes %}
      {% for content in contents %}
        <li><b>{{ note.title }}</b><br>{{ content }}</li>
  {% endfor %}
</ul>

您应该使用某种数据结构将您的内容与每条笔记相关联(假设没有 note.title 相同):

title_contents = {}
for note in result_list.notes:
    content = note_store.getNoteContent(auth_token, 
                                        note_store.getNote(note.guid, 
                                        True,False, False, False).guid)
    title_contents[note.title] = content

return render_to_response('oauth/callback.html', {'notebooks': notebooks, 
                                                  'result_list': result_list, 
                                                  'title_contents': title_contents})

在您的模板中:

<ul>
  {% for title, content in title_contents.items %}
    <li><b>{{ title }}</b><br>{{ content }}</li>
  {% endfor %}
</ul>