title: Django Admin TabularInline - Getting Foreign Key through a OneToOne Relationship
body: <p>As shown below, I want to display one model (<strong>Attendance</strong>) in the admin change view of another (<strong>Event</strong>) as a TabularInline. However, <strong>Attendance</strong> doesn't have a direct ForeignKey pointing to <strong>Event</strong>. Rather, it has a OneToOne relationship with <strong>Registration</strong>, which in turn points to <strong>Event</strong>. Any simple ways of achieving this?</p>
  
  <p>As you can see from the code, I tried to access the <strong>Event</strong> using a method, and pass it into the TabularInline class as <strong>fk_name</strong>, but it threw an error saying <em>"'myapp.Attendance' has no field named 'get_fk'"</em>.</p>
  
  <p><strong>myapp/models.py</strong></p>
  
  <pre><code>from django.db import models
  
  class Event(models.Model):
      ...
  
  class Registration(models.Model):
      event = models.ForeignKey(Event, on_delete=models.CASCADE)
      ...
  
  class Attendance(models.Model):
      registration = models.OneToOneField(Registration, primary_key=True, one_delete=models.CASCADE)
      ...
  
      def get_fk(self): 
          return self.registration.event
  </code></pre>
  
  <p><strong>myapp/admin.py</strong></p>
  
  <pre><code>from django.contrib import admin
  
  class AttendanceInline(admin.TabularInline):
      model = Attendance
      fk_name = 'get_fk'
  
  class EventAdmin(admin.ModelAdmin):
      inlines = [AttendanceInline]
  </code></pre>
  
  <p>My current workaround is to add another 'event' ForeignKey to <strong>Attendance</strong>, but it seems redundant as the same data is already stored inside 'registration'.</p>
  
  <p>Appreciate it if anyone could help!</p>