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>
答案 0 :(得分:1)
您应该使用某些数据结构将您的内容与每个音符相关联(假设没有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>