To begin with, let me tell you an interesting fact. Following on Instagram is quite different from friends on facebook. Friends in Facebook is a symmetrical relationship, I am your friend and hence you are my friend but following is not a symmetrical relationship, if you are interested in my stuff you can follow me and look at my stuff but I don't have to see your stuff until I am interested. Not exactly an interesting fact you expected but for the beginners like me, you got to know some technical terminology. There are many solutions to this problem and I am going to discuss the solutions I know. The first solution is a many to many relationships from the user table to itself. Don't be too confused and read the last line again. As you are following my blog you must be knowing what one to one and many to many relationships are. As your follower is also a user, a user can have many followers and many users can follow a user, Many to many relationships suit the situation. Done? Not really, told you it isn't that easy. In Django for any relation, the reverse is also possible. To be simple all relations are symmetrical by default. This troubled me a lot and then our friend StackOverflow help and there is a keyword argument that could be passed in order to prevent this symmetrical relation, that is "symmetrical=False". This was one way of doing it. Another way of doing it, which I found suited my need best was maintaining a different table for the relation, each record of this new table will be having two fields follower and following, both of them would be users, hence each relation would be stored in a table and it would be convenient for our needs such as follower count and following count. I want to say this again, that this approach is best suited to my needs in My opinion and this is not the standard or the best way if any other way suits your situation well feel free to use it.
In the last post, we discussed the error I have got and how I overcame those. In this blog, we will see how I dealt with AJAX. To begin with, all of you have used some social media like facebook, Instagram etc and all of them have some things in common. One of them is the like feature. Yow can like anything you find useful, fun or interesting. That simple "like" feature. Many of the normal users don't observe this actually, they don't have to observe this but whenever you hit the like button or double-tap in Instagram and the information that you liked that post is sent to the server, saved in the databases and some indication is given to you as well, so that you know that you have liked this post. All of this happens without the page getting reloaded. This sounds like usual stuff to the normal people but it's not as simple as it looks like. Not for an amateur web developer who has just started with web developing Generally, if we wish to make a get request to ...

Comments
Post a Comment