Django 2 by Example
上QQ阅读APP看书,第一时间看更新

Sharing posts by email

First, we will allow users to share posts by sending them emails. Take a short time to think how you would use views, URLs, and templates to create this functionality using what you have learned in the preceding chapter. Now, check what you need in order to allow your users to send posts by email. You will need to do the following things:

  • Create a form for users to fill in their name and 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