Hello, newbie here, I am currently making our capstone project as a requirement to our course subject, and it is a major subject, while I was in the part of retreiving the selected candidates, I was not about to iterate the vote for those selected on the upper part, just the last selected item/object/candidate, and since it is the major objective of our project, and I am stucked with it and our team will be screwed if I didn't finished it As Soon As Possible, here are my codes:
#views.py def vote(request): selected_candidate = Candidate.objects.get(pk= request.POST.get('candidate')) selected_candidate.totalvotes += 1 selected_candidate.save() return redirect('vs:index') #voting.html {% if all_candidates %} <form action="{% url 'vs:vote' %}" method="post"> {% csrf_token %} {% for organization in all_organizations %} {% if all_positions %} <h1>{{ organization.organization }}</h1> {% for position in all_positions %} {% if organization == position.organization %} <h3>{{ position.position }}</h3> <div class="row"> {% for candidate in all_candidates %} {% if position == candidate.position %} <div class="column"> <div class="col-md-4 col-sm-6 portfolio-item"> <div class="portfolio-link" data-toggle="modal"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <input type="checkbox" id="candidate{{ forloop.counter }}" class="candidate{{ position.id }} fa fa-check fa-3x" name="candidate" value="{{ candidate.id }}" /> </div> </div> <img src="{{ candidate.picture.url }}" class="img-responsive" /> </div> <div class="portfolio-caption"> <h4>{{ candidate.studentid.firstname }} {{ candidate.studentid.middlename }} {{ candidate.studentid.lastname }} {{ candidate.studentid.suffix }}</h4> <p class="text-muted">{{ candidate.position }} - {{ candidate.party }}</p> </div> </div> </div> {% endif %} {% endfor %} </div> {% endif %} {% endfor %} {% endif %} {% endfor %} <div class="intro-text"> <input type="submit" value="VOTE" class="page-scroll btn btn-xl"> </div> </form> {% else %} <h2>No Candidates Yet</h2> {% endif %} #models.py class Candidate(models.Model): studentid = models.OneToOneField(Student, on_delete=models.CASCADE) position = models.ForeignKey(Position, on_delete=models.CASCADE) party = models.ForeignKey(Party, on_delete=models.CASCADE) picture = models.ImageField() totalvotes = models.IntegerField(default=0) casvotes = models.IntegerField(default=0) citvotes = models.IntegerField(default=0) coevotes = models.IntegerField(default=0) ctevotes = models.IntegerField(default=0) I hope, you can help me guys, thank you so much in advance. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACY%3DutF4NhXucpewcHa3AnsrryT4wJ%2BZxZr_HWXF9%2BB88%2B-sog%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.