# Setting the last watched date

At the moment we're showing "Not watched yet" on every movie. If the have a date in the database for when the movie was last watched, we're using it, formatted with %d %b %Y.

In this lecture we will make both of those pieces of data clickable, and we will update the movie's last watched date using today's date as a value.

First, let's create an endpoint that, when clicked, will update the movie's last watched date.

# Create the Flask endpoint to update a movie watched date

Using what we learned in the last lecture, we can update the movie watched date with $set in MongoDB. We'll then pass in a Python datetime object (supported natively by pymongo), and that's it!

def watch_today(_id):
        {"_id": _id}, {"$set": {"last_watched": datetime.datetime.today()}}

    return redirect(url_for(".movie", _id=_id))

All we have to do in our template is add this link in, remembering to pass the movie ID:

 <div class="movie__watched">
     {% if movie.last_watched %}
-            Last watched: <a href="#" class="watched__link">
+            Last watched: <a href="{{ url_for('pages.watch_today', _id=movie._id) }}" class="watched__link">
                 <time datetime="{{ movie.last_watched }}">{{movie.last_watched.strftime("%d %b %Y")}}</time>
     {% else %}
-        <p><a href="#" class="watched__link">Not watched yet</a></p>
+        <p><a href="{{ url_for('pages.watch_today', _id=movie._id) }}" class="watched__link">Not watched yet</a></p>
     {% endif %}
     <a class="movie__edit" href="#">Edit {{ pencil("pencil") }}</a>

That's it! Now when we click this link, we'll trigger the Flask route which updates the date, and refreshes the page. You should be able to see today's date immediately in place of "Not watched yet".