Django OnlyFans Clone - Notifications Pt 1 | 22

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone and in this video we're going to work with the notification systems so yeah so let's stop the server and let's create a new app this app will be of course notifications okay we got a notification app now let's add notification apps to the let's join here to the main to install apps okay no notifications okay save okay now let's create our model so class notification models dot model okay so let's create notification types and so here in this tuple we're going to have um all the notification types for for our like objects so the first one will be um like we're going to get a like uh i mean we're going to get a notification every time a person like like one of the posts the second one will be comment and the third when a person actually subscribe to your channel not to your channel to your whatever um here we go okay so we got the notification types now we get the models the foreign key and then here we need to uh it's from jango.country.org let's import the user here so now here let's call the model's post by this way to avoid like circular imports so we call it this way [Music] on delete model cascade related name will be no notification post blank oops blank true no true okay so the sender will be foreign key user sender is basically the person that's the user that's sending the notification already from user and let's copy this and this one to user this one is the user receiving the notification um now notification type integer field and now here we make like choices uh then we basically pass the notification types because because um each integer like one two or three represents the type of notification it's just pass it over here um test preview for when our person is like commenting we're kind of gonna want to get a preview of the was the person but the person like comment so this one will have a mass length of um fifty fifty i split fifty um blank okay now the date date time field auto now add true okay we got the date now let's put each scene which means if the person saw the notification this one will be default false okay let's save that now let's run the migrations and then let's migrate okay we got our notifications now um let's work with each of the notifications and as we did in previous videos we're going to use this signals to basically um for example like for the like likes let's start with the likes so when a person like likes um a post and the likes it's created we want to basically create a notification um so down here um first we need to import the signals that we're going to use so let's go okay we have post save then whoops we need po verbs pause delete and yep so let's go down here okay okay here we are so as usual we we describe the function here so user like post this is when a user like a post so i'm gonna send her instance ours okay so like will be the instance post will be like post and the sender will be like user make sense so now um oh we need to import the model so let's go here from notifications that models import notification let me see yeah that's the name of the model oh yeah notification okay so um where are we okay we're here the most okay so so now 95 will be notification dot objects that filter oh no sorry this is right so notification we want to create the the when the person like i was about to do the like the delete but okay so post will be post sender sender and then user will be [Music] the post user basically the person that i created the post so um wait a couple one second oh yeah because we get the sender from the like user the person that's actually liking and we get the user i mean the person receiving notification from the post who's the person creating the post or the person who created the post so notification notification type notification type will be one notification type one because that's for the and save okay that's when the person like the post now let's find a person user unlike post because if the person like oh re regressing change their mind then take the like we want to delete notifications right so instance parts okay so here same thing like instant okay sender is of course kind of just we just yeah we just need to copy from that but it's fine it's okay so now notify just now we now we search so objects dot filter here post post sender sender and then not d3k naughty application type one we get that and then we basically delete very simple this is uh this is very easy to read i think that you can understand was all these two functions doing i think it's very easy to read that so now um now that we have our um oh ah very important we forgot to add this string let me check um never mind this so now here and this is sign out stuff or likes so now post save right dot connect and then we call likes that user like post that's the this is the function here so sender likes okay this is when a person this is safe after save so now after delete pause delete connect like that user unlike post sender likes very simple let's save that oh here we go um uh ah here we go i hate this wow oh that's what i like my sublime test honestly i don't know why this does that honestly it will be a plugin or something over here so we can kind of like clean the battery indentations or something right this is a headache honestly oh it's here the problem is the problem is here in the likes ah here we go i hate this seriously okay finally huh okay so so we finished the um so we finished the likes now let's jump to the comment that's the first the second one let me check yeah comment so let's go to the comment and basically we're going to do the same thing here so we can just um go to the post models we can just copy this bad idea but i'm not copying all of that so okay okay so user comment post user delete the comment post right um so comment comment sender um comment user so remember that we got like test preview here so test preview will be comment that body and then we basically take 50 characters from here um so notification post sender post user they're like test preview test preview notification type it's 2 and from here we need to run notifications data models import notification um uh yeah okay so now for the delete comment comment comment okay so now let's copy the signals we need to import the signals okay let's copy this one let's paste it over here hit save um of course sender is comment comment here comment remember to change it here this is very important if not it won't work so comment come and sign us okay so we got a comment um i think it should be fine so we got the comments now the last one will be tear which is when a person um subscribe right so let's get comments let's copy this stuff okay copy this and then here so boom so user let's just cry you sir subscribe um let's do is this user unsubscribe so here so correction subscription will be the instance so we don't need post so um we just need the sender will be the subscription subscriber remember this is the subscriber we don't need test preview so let's delete that so and then subscribing this is basically um the person receiving the the notification so subscribe so notify we don't need post actually let me check the notifications let me see if post uh let me see oh yes it can be can be no so okay so um notification sender um sender sender user it's subscribing here test preview we don't need it so we could buy notification type three um very simple so let's copy this one paste it here so um so same thing let's just copy this one and delete so now let's go to comment to copy the designers stuff okay um let's go again here to import this okay so let's fix this so connect um this one is subscription user subscribe sender um no subscription right and [Music] here and we save um i think okay i think we are done so this should work um [Music] so we got the we got the the models right so every time a user likes or notifies and stuff he sure um work for the for the user so now let's go to the admin because i want to see this in action so from notification that models import notification site register notification so um we which user okay build it so let's say the bill gates comment sorry so let's say the bill gates coming here um second comment let's say okay um now let's go to the ad oops now let's go to the admin and check notifications and here we go the notification was created and notification type comment second comment so apparently it's working so well apparently not it's working so let's go so now let's let's fix that let's fix the show notification so we can see
Info
Channel: Lara Code
Views: 1,218
Rating: undefined out of 5
Keywords: python3, tutorials, programming, software, softwarevdevelopment, juniordev, dev, python, tutorial2020, beginners, tutorial, linux, linuxonpython3, installingpythononlinux, setupforpython, inheritanceinpython, classesinpython, classpython, django, webframework, aws, amazonwebservices, lightsail, cloud, server, djangoinstagramclone, instagram, djangoinstagram, clone, webapp, django3.0, onlyfans, isntagram clone
Id: RKG-Bd8Xjwk
Channel Id: undefined
Length: 29min 40sec (1780 seconds)
Published: Tue Feb 09 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.