title: how to pass one function context variable to another function in django , or what is the good method instead of session for that?
body: <p>views.py</p>
  <pre><code>    def contest(request):
          context = {}
          all_contest = Contest.objects.all()        
          context[&quot;contest&quot;] = all_contest
          return render(request,&quot;contest.html&quot;,context)
      
      def contest_candidates(request,id):
          context = {}
          all_candidates_ = Contest_Candidates.objects.filter(contest_id = id)
          high_like = 0
          winner_ = &quot;&quot;
          for i in all_candidates_:
      
              if i.likes_count &gt; high_like:
                  high_like = high_like + i.likes_count
                  winner_ = i.owner.name
      
          context[&quot;cadidates&quot;] = all_candidates_
      
          return render(request,&quot;view_contest_candidates.html&quot;,context)
  </code></pre>
  <p>urls.py</p>
  <pre><code>path(&quot;contest&quot;,views.contest, name=&quot;contest&quot;),
  path(&quot;candidates/&lt;id&gt;&quot;,views.view_contest_candidates, name=&quot;candidates&quot;),
  </code></pre>
  <p>models.py</p>
  <pre><code>class Contest(models.Model):
      title = models.CharField(max_length=50)
  
  class Contest_Candidates(models.Model):
      image = models.FileField( upload_to=&quot;contest_candidates/&quot;,)
      owner = models.ForeignKey(CustomUser, on_delete=models.CASCADE)
      contest = models.ForeignKey(Contest, on_delete=models.CASCADE,related_name='candidates')
  
      @property
      def likes_count(self):
         return self.likes.all().count() 
  
  class CandidateLikes(models.Model):
      like = models.CharField(max_length=10)
      user = models.ForeignKey(CustomUser,on_delete=models.CASCADE,related_name='candidate_likes')
      contest_candidates = models.ForeignKey(Contest_Candidates, on_delete=models.CASCADE, related_name='likes')
  </code></pre>
  <p>how to pass the winner variable in to contest function ? i need to show that in contest.html</p>
  <p>if it's not possible,  which is the best method . want to show every contest winner in contest.html</p>