title: How do I get the actual object id in a Django admin page (inside formfield_for_foreignkey)?
body: <p>I 've already solved the problem of getting the object id being edited using this code:</p>
  
  <pre><code>class CompanyUserInline(admin.StackedInline):
      """
      Defines tabular rules for editing company users direct in company admin
      """
      model = CompanyUser
  
      def formfield_for_foreignkey(self, db_field, request, **kwargs):
  
          if db_field.name == "user":
              users = User.objects.filter( Q(is_superuser=False) )
              query = Q()
              for u in users:
                  aux = CompanyUser.objects.filter(user=u)
                  if aux.count() == 0:
                      query |= Q(pk=u.id)
  
              try:
                  cpu = CompanyUser.objects.filter(company__id=int(request.path.split('/')[4]))
                  for p in cpu:
                      query |= Q(pk=p.user.id)
              except:
                  pass
  
              kwargs["queryset"] = User.objects.filter(query).order_by('username')
  
          return super(CompanyUserInline, self).formfield_for_foreignkey(db_field, request, **kwargs)
  </code></pre>
  
  <p>But, the <em>int(request.path.split('/')[4])</em> is really ugly. I want to know how I get the id from the Django AdminModel. I'm sure it's somewhere inside it, anyone knows?</p>
  
  <p>Thank you in advance! ;D</p>