title: How can I pass objects to a custom django template tag? I figured out a way, but it seems hackish
body: <p>OK.  I am writing a system where users can "pick the winner".  I have a "matchup" table and a "picks" table.  On the matchup  webpage, I load all of the matchups for that day into the context along with all of the picks for that day.</p>
  
  <p>Now, I need to display checkmark images next to the choices to allow the user to "pick" that item (just like the "best answer" check on Stack Overflow)  In order to see which checks need to be in the down (picked) state (or up state, or "won state" or "lost state"), I am creating a template tag.</p>
  
  <p>Here is a relevant snippet from the template</p>
  
  <pre><code>  3 {% load matchup_tags %}
    4 
    5 {% for matchup in matchups %}
    6     &lt;div class="grid_6" style="margin-top:15px; border:1px solid black;"&gt;
    7 
    8             &lt;div class="div-status"&gt;&lt;span class="game-status"&gt;{{matchup.status}}&lt;/span&gt;&lt;/div&gt;
    9             &lt;div class="opt1"&gt;
   10                 &lt;div class="pick-home {% get_check matchup picks %}"&gt;
  </code></pre>
  
  <p>As you can see, the get_check template tag is executed in a loop.  I pass the current matchup, along with the list of picks to this template tag.</p>
  
  <p>Here is my "hacked" attempt at the template tag </p>
  
  <pre><code>  1 from django.template import Library, Node
    2 from matchup.models import *
    3 
    4 register = Library()
    5 
    6 class PickerNode(Node):
    7     def __init__( self , matchup , picks ):
    8         self.matchup , self.picks = matchup , picks
    9         
   10     def render(self, context):
   11         p = context['picks']
   12         return p[0].pick
   13     
   14 def get_check(parser, token):
   15     bits = token.contents.split()
   16     return PickerNode( bits[1] , bits[2] )
   17 
   18 get_check = register.tag(get_check)
  </code></pre>
  
  <p>If you look at line 12 from my template tag, I am using a context variable instead of the bits[2] variable(picks which was passed in from my view as "picks").  </p>
  
  <p>Am I able to pass objects to my template tags?  And why would I even bother if I can just access the object in the context.</p>
  
  <p>Edit:  Earlier, instead of using the context, I was doing something like
      "return self.picks.pick"
  and it was throwing some "unicode does not contain property 'pick'" error</p>
  
  <p>Cheers!</p>