Enabling our users to invite their friends carries many benefits. People are more likely to join our site if their friends are already using it. After they join, they will also invite their friends, and so on, which means an increasing number of users for our application. Therefore, it is a good idea to offer an " Invite a friend " feature. This is actually a common functionality found in many Web 2.0 applications.
Building this feature requires the following components:
An
Invitation
data model to store invitations in the databaseA form in which users can type the emails of their friends and send invitations
An invitation email with an activation link
A mechanism for processing activation links sent in email
Throughout this section, we will implement each component. But because this section involves sending emails, we first need to configure Django to send emails by adding some options to the settings.py
file. So, open the settings.py
file and add the following lines...