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.
First let’s fix something that we had from a previous tutorial. We…
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.
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…
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.
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…
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.
…
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.
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…
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.
This will look very similar to how we added…
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.
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…
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.
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. …
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.
First, let’s add…
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…