You do not need to use a form! Just create a new URL bound to the function that the "asterisks" send. for instance
(r'^myapp/star-post/(?P<post_id>.*)/$','myapp.views.myview')
Therefore, if you send a request to this URL, it will find the message in your database, changing the field to โfavoritesโ and return the response to ajax.
Then you can have a callback function on successful execution that changes CSS accordingly (fill the star, etc.). This way you do not need to worry about CSRF.
But you may ask, what about attacks on cross-site scripts! Well, if you use user authentication with cookie verification, you donโt have to worry about that! Aaaand, you are good to go.
source share