Sharing posts by email
First, let's allow users to share posts by sending them via email. Take a minute to think about how you could use views, URLs, and templates to create this functionality using what you learned in the preceding chapter. In order to allow your users to share posts via email, you will need to do the following things:
- Create a form for users to fill in their name, their email, the email recipient, and optional comments
- Create a view in the
views.py
file that handles the posted data and sends the email - Add a URL pattern for the new view in the
urls.py
file of the blog application - Create a template to display the form
Creating forms with Django
Let's start by building the form to share posts. Django has a built-in forms framework that allows you to create forms in an easy manner. The forms framework makes it simple to define the fields of your form, specify how they have to be displayed, and indicate how they...