Build and Handle POST Requests in Django – Part 3


In this four-part tutorial series, you’re building a social network with Django that you can showcase in your portfolio. This project is strengthening and demonstrating your understanding of relationships between Django models and showing you how to use forms so that users can interact with your app and with each other. You’re also making your site look good by using the CSS framework Bulma.

In the previous part of this tutorial series, you built templates and views for displaying a list of all profiles, as well as individual profile pages. You also learned how to apply style rules defined by the CSS framework Bulma to make your pages look good.

In the third part of this tutorial series, you’ll learn how to:

Create the front-end interface to let users follow and unfollow profiles
Submit and handle a POST request in Django using buttons
Set up the model for your text-based content
Build styled templates to display content on the front end
Use intricate model relationships in template code

At the end of this part, your social network will have all the pages you’d expect, and you’ll be able to create dweets on the back end and display them on the front end. Your users will be able to discover and follow other users and read the contents of the profiles that they follow. They’ll also be able to click a button that sends an HTTP POST request handled by Django to unfollow a profile if they want to stop reading a certain user’s content.

You can download the code that you’ll need to start the third part of this project by clicking the link below and going to the source_code_start/ folder:

Get Source Code: Click here to get the source code you’ll use to build and handle POST requests with Django.


In this four-part tutorial series, you’re building a small social network that allows users to post short text-based messages. The users of your app can also follow other user profiles to see the posts of those users or unfollow them to stop seeing their text-based posts:

You’re also learning how to use the CSS framework Bulma to give your app a user-friendly appearance and make it a portfolio project you can be proud to show off!

In the third part of this tutorial series, you’ll continue working with Bulma-styled templates, and you’ll create the model for your text-based message content. You’ll also set up and handle HTTP POST request submissions on your Django app’s front end, which will allow users to follow or unfollow each other by clicking a button:

At the end of this tutorial, each user will be able to go to a new dashboard page to access a personal feed of dweets that’s based on which profiles they follow. They’ll also be able to follow and unfollow other users. That’s a giant leap ahead for your Django social network!

Project Overview

In this section, you’ll get an overview of what topics you’ll cover in this third part of the tutorial series. You’ll also get a chance to revisit the full project implementation steps, in case you need to skip back to a previous step from earlier in the series or if you want to see what’s still up ahead.

At this point, you should have finished working through parts one and two of this tutorial series. If you did, then you’re now ready to continue with the next steps of this tutorial series. These steps focus on the code logic for following and unfollowing profiles, as well as how to set up dweets:

After completing all the steps in the third part of the tutorial series, you can continue with part four.

To get a high-level idea of how you’re working through all four parts of this tutorial series on building your Django social network, you can expand the collapsible section below:

You’re implementing the project in a number of steps spread out over multiple separate tutorials in this series. There’s a lot to cover, and you’re going into detail along the way:

✅ Part 1: Models and Relationships

Step 1: Set Up the Base Project
Step 2: Extend the Django User Model
Step 3: Implement a Post-Save Hook

✅ Part 2: Templates and Front-End Styling

Step 4: Create a Base Template With Bulma
Step 5: List All User Profiles
Step 6: Access Individual Profile Pages

📍 Part 3: Follows and Dweets

Step 7: Follow and Unfollow Other Profiles
Step 8: Create the Back-End Logic For Dweets
Step 9: Display Dweets on the Front End

⏭ Part 4: Forms and Submissions

Step 10: Submit Dweets Through a Django Form
Step 11: Prevent Double Submissions and Handle Errors
Step 12: Improve the Front-End User Experience

Each of these steps will provide links to any necessary resources. By approaching the steps one at a time, you’ll have the opportunity to pause and come back at a later point in case you want to take a break.

With the high-level structure of this tutorial series in mind, you’ve got a good idea of where you’re at and which implementation steps you’ll handle in the last part.

Before getting started with the next step, take a quick look at the prerequisites to skim any links to other resources that might be helpful along the way.


To successfully work through this part of your project, you need to have completed the first part on models and relationships and the second part on templates and styling, and you should confirm that your project is working as described there. It would be best if you’re also comfortable with the following concepts:

Read the full article at »

[ Improve Your Python With 🐍 Python Tricks 💌 – Get a short & sweet Python Trick delivered to your inbox every couple of days. >> Click here to learn more and see examples ]