5.4. Tying Everything TogetherBecause we're redirecting everybody to the index method, we probably ought to create one. So, here goes: <body> <h2><a href="/list_by_category">Bookmarks by Category</a></h2> <h2><a href="/list">All Bookmarks</a></h2> <h2><a href="/bookmarks/add">Add New Link</a></h2> </body> This is just plain HTML, but it uses the bookmark, list, and list_by_categories URLs that we defined earlier. Before we finish things off, we really need to add a link to each of our bookmarks in the /list page that will allow a user to edit that bookmark: <body> <ul> <li py:for="bookmark in bookmarks"> <a href="${bookmark.link}"> <span py:replace="bookmark.bookmarkName">Link to Bookmark</span> </a> -- <span py:replace="bookmark.description">Description of the Bookmark goes here. </span> <br /> <a href="${'/bookmark/edit/'+str(bookmark.id)}">edit</a> -- <b> Categories: </b> <span py:for="cat in bookmark.categories"> ${cat.categoryName} </span> <hr width="300" align="left"/> </li> </ul> </body> In this little template, we have a loop for each bookmark in the database, and an inner loop for each category attached to that bookmark. This gives us a nice listing of the bookmark name and description, along with a link to the edit page for that specific bookmark. All of this is followed by a list of the categories that bookmark is related to. |