title: Django How do i Insert data without refreshing or reloading page
body: <p>How to do in django to return with the current page after the user insert their data (request.post)</p>
  
  <p>scenario:</p>
  
  <p><em>If the teacher insert the grades of their students, the current page will reload or refresh</em>.</p>
  
  <p>I don't know if I can achieve it by using redirect. </p>
  
  <pre><code>def grades(request):
      V_insert_data = StudentSubjectGrade(
            ...
      )
    V_insert_data.save()
  
    //redirect the same page
  
  
  def teacher(request):
      if request.method != 'POST':
          raise Http404('Only POSTs are allowed')
      try:
           ......
           return render(request, 'Homepage/index.html')
      except EmployeeUser.DoesNotExist:
          messages.warning(request, 'Your Username and password are Incorrect.')
          ….
      return render(request, 'Homepage/TeacherLogin.html')
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>path('teacher/', Homepage.views.teacher, name='teacher'),
  path('grades/', Homepage.views.grades, name='grades'),
  </code></pre>
  
  <p>this is the error i get</p>
  
  <p><a href="https://i.stack.imgur.com/bpyxO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bpyxO.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>when I change my</p>
  
  <pre><code>  response = redirect(teacher)
    return response
  </code></pre>
  
  <p>to this</p>
  
  <pre><code>return redirect(reverse('teacher'))
  </code></pre>
  
  <p>i get the same result</p>
  
  <p><strong>UPDATE</strong> again</p>
  
  <p>when I tried this </p>
  
  <pre><code>def grades(request):
      V_insert_data = StudentSubjectGrade(
            ...
      )
    V_insert_data.save()
  return HttpResponseRedirect(request.path_info)
  </code></pre>
  
  <p>I get this error</p>
  
  <p><a href="https://i.stack.imgur.com/Z95U4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z95U4.png" alt="enter image description here"></a></p>
  
  <p>ive already clear my cookies but still this error appear</p>