title: Django - avoid false records if the pk of a dynamic url is changed
body: <p>I am designing an app where students can rate their teachers through a survey. </p>
  
  <p>Basically what the app does is it generates a dynamic url for each teacher, for example:</p>
  
  <ul>
  <li>Teacher Mike : mywebsite.com/teacher/1</li>
  <li>Teacher Brian: mywebsite.com/teacher/2</li>
  </ul>
  
  <p>The numbers correspond to the PK of each teacher. The student fills out the survey and when sending it, first validates in the database that the answers have not been sent previously (to avoid duplicates). In case the answer has already been saved before, a page is displayed where it says this.</p>
  
  <p>Everything works fine, but there is a problem if the user (student) performs a strange action. When the student rates for example the  Teacher Mike :  the url that is generated is mywebsite.com/teacher/rate/1 and shows a template that says that the answer is saved. The problem comes here:</p>
  
  <p>If the person at that time changed the number(pk) in the url, for example from 1 to 2, the app saves the teacher-1's answers in the teacher-2's record. </p>
  
  <p><strong>clarification</strong>: if the student is assigned teachers 1, 2 and 3 and changes the pk in the url to 5, there is no problem since the app detects that the student does not have permission to grade that teacher. The problem is if it is changed from 1 to 3, for example, since the student has permission to grade both students.</p>
  
  <p>I know it's strange behavior. But I'd like to find a way to solve this.</p>
  
  <p>The view for submitting the answers is this:</p>
  
  <pre><code>def send(request, user_pk):
      if not request.user.is_authenticated:
          return HttpResponseRedirect('/accounts/login/')
      else:
          #first look for the record not to exist in the DB to avoid duplicate records
          exist = Answers.objects.filter(name= request.user, teacher= user_pk ).exists()
          # if there is not then I proceed to create the record in the database
          if exist == False:
              for key, value in request.POST.items():
                  if clave != 'csrfmiddlewaretoken':
                      Answers.objects.create(question=int(clave), answer_to_question=int(valor), student = request.user,teacher = int(user_pk)) 
              #then I change a record in the table of my DB where the finished evaluations are stored, from false to true.  
              actual_state= State.objects.get(student__name = request.user, teacher = user_pk)
              actual_state.finished_evaluation = True
              actual_state.save()
              return render(request,"myapp\send.html") 
          else:
              return render(request,"myapp\error.html") 
  </code></pre>