O'Reilly logo

Django Project Blueprints by Asad Jibran Ahmed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Voting

We need to allow users to vote on submissions. To keep things simple, we'll only allow upvotes. A user can indicate that they like a submission. There is no way to indicate disapproval. This keeps the code and UI simple. We also want to ensure that one user can upvote a submission only once and they can remove their upvotes if they change their minds or upvoted a submission by mistake.

If you take another look at the Link model, you'll see we already have an upvotes field, which is a Machine to machine (M2M) with the User model. This is the only database entry we'll need to allow and keep track of upvotes by users. In order to upvote a submission, users will click on a link next to the submission. Until now, we were able to make do without ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required