title: How to add function for counting correct answer in django api?
body: <p>I am creating quiz application in django .I created result page ,but in result page every time it shows correct ans = 0 ..plz suggest how can i change logic behind this ...plz...plz</p>
  <p>**Code for view.py **</p>
  <pre><code>from django.shortcuts import render,redirect
  from django.contrib.auth import login,logout,authenticate
  from .forms import *
  from .models import *
  from django.http import HttpResponse
   
  # Create your views here.
  def home(request):
      if request.method == 'POST':
          print(request.POST)
          questions=QuesModel.objects.all()
          score=0
          wrong=0
          correct=0
          total=0
          for q in questions:
              total+=1
              print(request.POST.get(q.question))
              print(q.ans)
              print()
              if q.ans ==  request.POST.get(q.question):
                  score+=10
                  correct+=1
              else:
                  wrong+=1
          percent = score/(total*10) *100
          context = {
              'score':score,
              'time': request.POST.get('timer'),
              'correct':correct,
              'wrong':wrong,
              'percent':percent,
              'total':total
          }
          return render(request,'result.html',context)
      else:
          questions=QuesModel.objects.all()
          context = {
              'questions':questions
          }
          return render(request,'home.html',context)
  </code></pre>
  <p>Code for Model.py</p>
  <pre><code>from django.db import models
  
  # Create your models here.
  class QuesModel(models.Model):
      question = models.CharField(max_length=200,null=True)
      op1 = models.CharField(max_length=200,null=True)
      op2 = models.CharField(max_length=200,null=True)
      op3 = models.CharField(max_length=200,null=True)
      op4 = models.CharField(max_length=200,null=True)
      ans = models.CharField(max_length=200,null=True)
      
      def __str__(self):
          return self.question
  </code></pre>