Recommending posts by email
We will allow users to share blog posts with others by sending post recommendations via email. You will learn how to create forms in Django, handle data submission, and send emails with Django, enhancing your blog with a personal touch.
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.
To allow users to share posts via email, we will need to:
- Create a form for users to fill in their name, their email address, the recipient’s email address, 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...