Fetching contributors…
Cannot retrieve contributors at this time
64 lines (49 sloc) 1.94 KB

{% raw %} In order to view the contact we will have to do three things: create the handler that will retrieve the contact from the datastore, the template to view her in the browser and the link on the contact list for easy access.

Contact View Handler

Add the following code to the file:

def contact_view(contact_id):
  contact_db = model.Contact.get_by_id(contact_id)
  if not contact_db or contact_db.user_key != auth.current_user_key():
  return flask.render_template(

Contact View Template

After creating the handler, we are going to need a template to be able to present a contact's personal page. Create a new file contact_view.html in the templates directory and paste the following code there:

# extends 'base.html'

# block content
  <div class="page-header">
    <a href="{{url_for('contact_list')}}">Back</a>
# endblock

It's hard to test this form right now because we have to create manually the URL, but in the next section we'll add a link to make it easier to access.

Finalise Contact View

As a final touch in order to view the contacts we'll modify the contact list so when you click on their names you should be able to view them.

Find the line that renders the name of the contact and replace it with the following:

  <a href="{{url_for('contact_view',}}">

Now visit the contact list (http://localhost:3000/contact/), and you should be able to click on the name of each contact and view their properties.

{% endraw %}