Day 2 of the Anvil Advent Calendar

Build a web app every day until Christmas, with nothing but Python!

There are only 22 shopping days left until Christmas!

If your friends and family haven’t already bought you everything you’ve always wanted, they might need some digital assistance.

Enter Christmalist! The sofware-as-a-service solution for your yuletide purchasing needs.

It’s a wishlist, stored online, that you can share with your friends. Your friends can check off what they’ve bought to avoid double-buying.

Building a list

Here’s my wishlist:

This is a simple CRUD app - the “wish” button adds my items to a Data Table, with the ‘Owner’ column set to the Users row for whoever is logged in.

The owner column stores who wants each item.

The owner column stores who wants each item.

You’ve got to be logged in to make a list, so the first time the “wish” button is pressed, I display a login form using:


Sharing with friends

To share your list with a friend, you simply enter their email address:

The email is sent using
      subject=f"{user['email']} wants to share their wishlist with you on Christmalist!",
        {user['email']} wants to share their wishlist with you on Christmalist!
        Follow this link to see it:{user['email']&k={key}}
        <h1 style="color: #D32F2F">View your friend's wish list!</h1>
        {user['email']} wants to share their wishlist with you on Christmalist!<br><br>
        <a href="{user['email']}&k={key}">Click here</a> to see it!

This email contains a link to Christmalist, with some query parameters that dictate whose list is being shared, and a random key to make sure people don’t randomly invent these links for themselves. Here’s an example:

The ‘Users’ table stores a list of valid keys. I check the k query param against the sharing_keys column to check that the link is valid.

Viewing your friends’ lists

Finally, you can view your friends’ lists by selecting them from a dropdown. If you’ve purchased that item for them, you can check the box so nobody else buys the same thing!

Go ahead and use it

The app is published at - go ahead and use it to streamline your present-receiving this year!

You can get the source code for yourself – you could even make a business out of it, using Anvil’s Stripe integration to take payments!

To get started, get your own copy of the source code, and tweak it however you like:

Give the Gift of Python

Share this post: