title: django admin inlines: get object from formfield_for_foreignkey
body: <p>I am trying to filter the options shown in a foreignkey field, within a django admin inline. Thus, I want to access the parent object being edited. I have been researching but couldn't find any solution.</p>
  
  <pre><code>class ProjectGroupMembershipInline(admin.StackedInline):
      model = ProjectGroupMembership
      extra = 1
      formset = ProjectGroupMembershipInlineFormSet
      form = ProjectGroupMembershipInlineForm
  
      def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
          if db_field.name == 'group':
              kwargs['queryset'] = Group.objects.filter(some_filtering_here=object_being_edited)
          return super(ProjectGroupMembershipInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  </code></pre>
  
  <p>I have verified that kwargs is empty when editing an object, so I can't get the object from there.</p>
  
  <p>Any help please? Thanks</p>