title: How can I display the data from a foreign table in a table cell using django-tables2 (custom table)?
body: <p>The value on the table cell is empty. This column contains the data from foreign table.</p>
  
  <p>Here is the snippet of my models.</p>
  
  <p>model.py</p>
  
  <pre><code>class DailyRecord(models.Model):
      date_organised = models.DateField('Ogransied Date', help_text=('Enter Date when the program is organised: CCYY-MM-DD'))
      program_name = models.TextField('program name',)
      venue = models.CharField('venue', max_length = 255, blank=True)
      organiser = models.ForeignKey(Organiser, verbose_name = 'Organiser', related_name = 'organisers')
  
      objects = models.Manager()
      public = DailyRecordManager()
  
  
      class Meta:
          verbose_name = 'dailyrecord'
          verbose_name_plural = 'dailyrecords'
         ordering = ['-date_organised']
  
      def __str__(self):
          return self.program_name.encode('ascii', errors='replace')
  
  class Participant(models.Model):
      participant = models.CharField(max_length= 50)
      daily_record = models.ForeignKey(DailyRecord, verbose_name = 'program_name', related_name = 'participant_set')
  
      class Meta:
          verbose_name = 'participant'
          verbose_name_plural = 'participants'
  
      def __str__(self):
          return self.participant.encode('ascii', errors='replace')
  </code></pre>
  
  <p>This is class on table to display custom table. below is the snippet</p>
  
  <p>tables.py</p>
  
  <pre><code>class DailyRecordTable(tables.Table):
      date_organised = tables.Column('Date')
      program_name = tables.Column( 'Program Name')
      venue = tables.Column('Venue')
      organiser = tables.Column( 'Organiser')
      participant = tables.Column(accessor='participant.participant')
  
      class Meta:
          model = DailyRecord
  </code></pre>
  
  <p>This is my Generic Views for displaying table.</p>
  
  <p>views.py</p>
  
  <pre><code>class DailyActivityPageView(SingleTableView):
      queryset = DailyRecord.public.prefetch_related('participant_set').all()
      table = DailyRecordTable(queryset)
  
      template_name = 'dailyrecord/daily-activity-record.html'
      def get(self, request):
          RequestConfig(request).configure(self.table)
          return render(request, self.template_name, {'table': self.table, 'ziptable':self.ziptable,'data' : self.data})
  </code></pre>
  
  <p>data.html</p>
  
  <pre><code>&lt;tbody&gt;
    {% for row in table.page.object.list|default:table.rows %} {# support pagination #}
    {% block table.tbody.row %}
    &lt;tr {{ row.attrs.as_html }}&gt;
    {% for column, cell in row.items %}
    &lt;td {{ column.attrs.td.as_html }}&gt; 
    {{cell}}
    {% if column.localize == None %} 
    {% if column.header == 'Participant' %}
    {{cell}}
    {% for item in cell.participant_set.all %}
         {{item.participant}}
     {% endfor %}
  {% else %}                                                                              
    {{ cell}} 
  {% endif %}
   {% else %}
   {% if column.localize %}                                                        
     {{ cell|localize }}
   {% else %}                                                                 
    {{cell|unlocalize}}
   {% endif %}
   {% endif %}
   &lt;/td&gt;
   {% endfor %}
   &lt;/tr&gt;
   {% endblock table.tbody.row %}
   {% empty %}
   {% if table.empty_text %}
    {% block table.tbody.empty_text %}
    {% endblock table.tbody.empty_text %}
   {% endif %}
   {% endfor %}
   &lt;/tbody&gt;
  </code></pre>
  
  <p>Output <a href="https://i.stack.imgur.com/o7vqw.jpg" rel="nofollow noreferrer">screenshot</a> </p>
  
  <p>The participant column is empty. Why?</p>