title: Django Form: Calling foreign key field attributes in template
body: <p>In a template I want to call a class attributes of a foreign-key form field <em>item.pid</em> like shown below</p>
  <pre class="lang-html prettyprint-override"><code>{%for item in form.item %}
  {{item.pid}}
  {% endfor %}
  </code></pre>
  <p>My question is simple and the solution should be as well but I am stuck here for way too long now. I have tried formsets, inlineformsets, clean and so many more things which are in the documentation and here on SO.
  It's even not possible to call a class method of a form field.</p>
  <p>calling <em>{{form.instance.item.pid}}</em> should be the solution but I can't get it running.</p>
  <p><strong>model.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>class Event(models.Model):
      person = models.ForeignKey(Person, on_delete=models.CASCADE, blank=True, null=True, default=0)
      item = models.ForeignKey(Item, on_delete=models.CASCADE, blank=True, null=True, default=0)
  #many more
  
  class Person(models.Model):
      person_number = models.IntegerField(null=True)
      name = models.CharField(max_length=200, null=True)
      surname = models.CharField(max_length=200, null=True)
  #many more
  
  class Item(models.Model):
      person = models.ForeignKey(Person, on_delete=models.CASCADE, blank=True, null=True, default=0)
      pid = models.IntegerField(null=True) 
  #many more
  
      def save(self, *args, **kwargs):  
          self.pid = Person.objects.filter(surname=self.person.surname, name=self.person.name).values(&quot;person_number&quot;)
          super(Item, self).save(*args, **kwargs) 
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>def event(request, event_id=None):
  
      if event_id:
          instance = get_object_or_404(Event, pk=event_id)
      else:
          instance = Event()
     
      form = EventForm(request.POST or None, instance=instance)    
  
      if request.POST and form.is_valid():
          form.save()
          return HttpResponseRedirect(reverse('cal:calendar'))
      context = {
          'form': form,
      }    
      return render(request, 'cal/event.html', context)
  </code></pre>
  <p><strong>forms.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>class EventForm(ModelForm):
    class Meta:
      model = Event
  
      fields = ('person', 'item', 'manymore',)
  </code></pre>