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 app 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 are 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 are the states:
- This is an inactive state, where you can click on a button to activate it:
- This is an 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.