Video Tutorial

Code on Github

In this tutorial, we are going to add user notifications to our social media app. We will set up notifications that will be in the navigation bar that will list all unseen notifications. For our app, we will count a notification as unseen if they haven’t clicked on it. This will definitely be more involved and not as simple as the previous changes we have made. To make this all work we will mix in a little Javascript and custom Django template tags.

Move the Javascript Script Tag

First let’s fix something that we had from a previous tutorial. We…


Video Tutorial

Code on Github

There will be a couple more tutorials for this social network, in this one we will add the ability to like/dislike comments and reply to comments. We won’t keep adding replies to replies, etc but we will allow the comments directly on the post to have replies. Let’s get started by adding likes and dislikes to the comment model.

Adding Likes and Dislikes to Comments

We need to add the same thing that we had in our Post model for the likes and dislikes, this will look almost exactly the same. We just need to change the related_name to be something…


Video Tutorial

Code on Github

In this tutorial, we are going to finish up making some small final improvements to the application. This time, we are going to add a way to view a list of followers, we will improve the profile styles, and we will fix an issue with the navbar profile link. Let’s start with adding a followers list.

Adding a List of Followers

First we need to create a new view to get all of the followers. This will be very similar to other views that we have created. We will use the generic view class and get the profile from the…


Video Tutorial

Code on Github

This will be part 1 of two tutorials where we will put some final improvements on our social media application. We have most of the functionality done at this point, we just need to clean some things up and add a couple of additions to improve the user experience. In this first tutorial, we will add an external style sheet to clean up our templates, we will filter the social feed to only show posts by those users that we follow, and we will update some of the header text for the posts and comments.

External CSS


Video Tutorial

Code on Github

In this tutorial, we are going to get the user search bar that has been in our navbar working. We will use the Q object that comes with Django to get this working. We will need to make some changes to our navbar first.

Updating the Navbar

We need to add a method and an action to the form, this action url isn’t created yet, but we will name the url pattern the same as this when we create it later. We also need to add a submit button, for this we will use a font awesome icon…


Video Tutorial

Code on Github

In this tutorial, we are going to add the ability to like and dislike posts. To do this, we will store a list of users that clicked the like or the dislike button. We will add some checks to make sure that the user can only like or dislike a post once and they can only either like or dislike a post and not both at the same time. First we need a place to store this data, we will add that to our Post model.

Add to The Models.py

This will look very similar to how we added…


Video Tutorial

Code on Github

In this tutorial we are going to add the ability to follow and unfollow users. We will create two simple views that will handle the logic for this. We will need to update our models.py to have a field to store the followers for each user. Before we do this, we are going to update the post lists to have a link to go straight to the profile.

Adding a Profile Link on the Post Lists

First, we want to add a link to easily access the profile of each user. We will do this by changing the post lists in the…


Video Tutorial

Code on Github

In this tutorial, we are going to add profiles to our app. We will add a way to view and edit profiles from a link in the navbar. We will also use Django signals to automatically create profiles once a user is created. Let’s get started with updating the models.py file in our social app.

Setting up the Profile Model

social/models.py:

First we will add a UserProfile model, this will hold a foreign key in the form of a one to one relationship with the user model. We will also hold some extra data on the user here. …


Video Tutorial

Code on Github

In this tutorial we are going to finish our post and comment functionality. First, we need to add the ability to edit and delete posts. We also need to make sure to only allow this to the user who originally created the post. After that, we will need to add the ability to add comments and delete comments. We also need to restrict the edit and delete views to be only accessible by the user who created the post/comment. Let’s get started by adding the edit and delete views for the posts.

Editing and Deleting Posts

First, let’s add…


Video Tutorial

Code on Github

In this tutorial, we are going to add to the posts feature of our social app by adding the ability to get a single post and set up the comment model. Let’s first start by fixing a couple issues from the the last tutorial. The redirect is not working correctly for logged in users, we also want to change the home link in the navbar brand to go to the social feed if a user is logged in. Let’s open up or settings.py to fix the login redirect first:

LOGIN_REDIRECT_URL = 'post-list'

And then we…

LegionScript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store