You can create a view with an argument for the Mainnews objects primary key (you can do it in URL like this /main-news/1/like or you can post it in request.POST)
Then in your like view (create a view that does not need authentication) get the object from the database and do this:
main_news.likes = main_news.likes + 1
your view must be POST because you want to change the db.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…