Video Tutorial

Code on Github

In this tutorial we will add the basic functionality for tagging in posts and comments. To do this, we will add a new field to our post and comment model, we will add a method to those models as well and then to finish it up we will add some Javascript to change all of the tag text to be links. We will add the rest of the functionality for an explore page and the links in the next tutorial.

Adding Tags to the Models

First we just need to add a new field to the models. Here is the…


Video Tutorial

Code on Github

In this series, we will go through the different parts of the Django framework, unlike other series. This won’t be about building any project specifically. This will just be about improving your understanding of the Django framework. This will be on top of the other project tutorials. Those will still be posted about once a week. In this first tutorial we will go over the basics of Django models and the different options available to us.

What are Django Models?

Django models are a way to create different object in the database, usually a model class maps to a…


Video Tutorial

Code on Github

In this tutorial we will be adding the ability to share another users post. To do this we will add more fields to our Post model and we will update our forms, views and templates to handle this new feature. Let’s get started by adding to our models.py.

Adding Additional Fields to the Post Model

We need to add some additional fields to handle if a user is sharing another post, to do this we want to create a new post with the original post’s information but also include the sharing user, the date it was shared, and if they entered some…


Video Tutorial

Code on Github

In this tutorial we will add the ability to upload multiple images to posts. We will just need to make a few changes to our models, form, views, and templates where we are already handling images. Let’s start with the models.py file.

Updating models.py

To make this work, we will need to add another model for the image. We can then add a ManyToMany field. This will allow us to store multiple images.

class Post(models.Model):  body = models.TextField()  image = models.ManyToManyField('Image', blank=True, null=True)  created_on = models.DateTimeField(default=timezone.now)  author = models.ForeignKey(User, on_delete=models.CASCADE)  likes = models.ManyToManyField(User, blank=True, related_name='likes')


Video Tutorial

Code on Github

In this tutorial, we will add some extra features to our direct messages. We will add a notification when a user receives a message, we will add an alert if a thread is created with a username that doesn’t exist. We will also add the ability to upload images inside of messages as well. Finally, we will change some CSS styles as well. Let’s get started by adding a notification when a message is created.

Adding a Notification for Messages

First we need to add another notification type, we will need to add a thread field and we will add…


Video Tutorial

In this tutorial we are going to start to add direct messages between users. In this part we will get it working with it’s basic functionality and then we will come back and add some extra features to it next. This will not be a real time chat, to do that would be more complicated and would require something like Django channels. If there is any interest in that, I could come back later and update it to include that. However for now, we won’t do that. …


Video Tutorial

Code on Github

In this tutorial, we are going to add more to our social network application. This time we will add the ability to upload a image in a post. We will add a button to select a file and then we will show it above the text of the post. We will need to make some updates to our PostModel to handle this. Let’s first start with fixing a small bug in the social feed.

Fixing a Social Feed Bug

The first thing to do is to fix the issue with our social feed, there is an issue where the posts…


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…

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