Websites in general, and most commonly those with a social component, often have integrated Facebook, Twitter, and Google+ widgets to like and share content. In this recipe, we will guide you through the building of a similar Django functionality that will save information in your database whenever a user likes something. You will be able to create specific views based on the things that people liked on your website. We will similarly create a Like widget with a two-state button and badge showing the number of total likes.
The following screenshot shows the inactive state, where you can click on a button to activate it:
The following screenshot shows the active state, where you can click on a button to deactivate it:
Changes in the state of the widget will be handled by Ajax calls.