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 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 Bulma CSS framework.
In the previous part of this series, you added functionality so that users can create dweets on the back end and display them on the front end. At this point, your users can discover and follow other users and read the content of the profiles they follow. They can click a button that sends an HTTP POST request handled by Django to unfollow a profile if they want to stop reading their content.
In the fourth part of this tutorial series, you’ll learn how to:
Create and render Django forms from your Dweet model
Prevent double submissions and display helpful error messages
Interlink pages of your app using dynamic URLs
Refactor a view function
Use QuerySet field lookups to filter your data on the back end
Once you finish going through this final part of the tutorial, you’ll have a fully functional basic social network built with Django. It’ll allow your users to create short text-based messages, discover and follow other users, and read the content of the profiles they follow. They’ll also be able to unfollow a profile if they want to stop reading their content.
Additionally, you’ll have showcased that you can use a CSS framework to make your web app look great without too much extra effort.
You can download the code that you’ll need to start the final 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 submit HTML forms with Django.
Demo
In this four-part 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 these 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 fourth and final part of this tutorial series, you’ll learn how to build Django forms on top of an existing model. You’ll also set up and handle more HTTP POST request submissions so that your users can post their text-based messages.
At the end of this tutorial, you’ll have completed your basic social network built with Django. By then, your users will be able to navigate to a profile list and to individual profile pages, follow and unfollow other users, and see the dweets of the profiles they follow displayed on their dashboard. They’ll also be able to submit dweets through a form on their dashboard.
Project Overview
In this section, you’ll get an overview of what topics you’ll cover in this final 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 that you completed in an earlier part of the series.
At this point, you should have finished working through parts one, two, and three of this tutorial series. Congratulations! You’ve made your way to the final part, which focuses on building forms and handling form submissions:
Once you’ve implemented the steps of this last part of the series, you’ve completed the basic version of your Django social network. You’ll be ready to take any next steps by yourself to make this project stand out in your web developer portfolio.
To get a high-level idea of how the final part in this series on building your Django social network fits into the context of the whole project, 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 details 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
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 might have to catch up on, if you haven’t completed them yet.
Before getting started with the next step, take a quick look at the prerequistes to skim any links to other resources that might be helpful along the way.
Prerequisites
To successfully work through this final part of your project, you need to have completed the first part on models and relationships, the second part on templates and styling, and the third part on follows and dweets. Please confirm that your project works as described there. You should also be comfortable with the following concepts:
Read the full article at https://realpython.com/django-social-forms-4/ »
[ 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 ]