title: 'RelatedManager' object has no attribute 'pk'
body: <p>I have a model that looks like this</p>
  
  <pre><code>class Connections(models.Model):
      following = models.ForeignKey(
          User, related_name='following'
      )
      followers = models.ForeignKey(
          User, related_name='followers'
      )
      def __unicode__(self):
          return u'%s, %s' % (self.following.username, self.followers.username)
      class Meta:
          unique_together = (('following', 'followers'), )
  </code></pre>
  
  <p>And then in TastyPie I am using the following code to extract the following users</p>
  
  <pre><code>class ConnectionsResource(ModelResource):
      user_following = fields.ForeignKey(UserResource, 'following')
      user_follower = fields.ForeignKey(UserResource, 'followers')
      class Meta:
          queryset = Connections.objects.all()
          resource_name = 'connections'
  
      def prepend_urls(self):
          return[
              url(r"^(?P&lt;resource_name&gt;%s)%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('connections'), name="api_connections"),
          ]
  
      def connections(self,request,**kwargs):
          if request.user and request.user.is_authenticated():
              #Scribble Comments
              if request.GET.get('followers', ''):
                  user = request.user
                  followers = [connections.following for connections in user.followers.all()]
                  followers_count = 1
                  if followers_count &gt; 0:
                      paginator = Paginator(followers, 20)
                      try:
                          page = paginator.page(int(request.GET.get('page', 1)))
                      except InvalidPage:
                          return self.create_response(request, { 'success': False, 'reason':'no more pages' })
                      objects = []
                      for result in page.object_list:
                          bundle = self.build_bundle(obj=result, request=request)
                          bundle = self.full_dehydrate(bundle)
                          objects.append(bundle)
                      followers_list = {
                      'followers_count': followers_count,
                      'followers' : objects,
                      'success': True,
                      }
                      self.log_throttled_access(request)
                      return self.create_response(request, followers_list)
                  else:
                      return self.create_response(request, { 'success': False, 'reason':'No Followers' })
              else:
                  return self.create_response(request, { 'success': False, 'reason':'Wrong Query'})
          else:
              return self.create_response(request, { 'success': False, 'reason':'User not Logged in'})
  
      def determine_format(self, request):
          return 'application/json'
  </code></pre>
  
  <p>But I keep on getting the <code>'RelatedManager' object has no attribute 'pk'</code> error. I am not sure why</p>
  
  <p>Traceback:</p>
  
  <pre><code>traceback: "Traceback (most recent call last): 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/resources.py", line 202, in wrapper response = callback(request, *args, **kwargs) 
  File "/Users/jonathan/virtualenvs/myproject/bin/django_worksquid/scribbler/api.py", line 547, in connections bundle = self.full_dehydrate(bundle) 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/resources.py", line 837, in full_dehydrate bundle.data[field_name] = field_object.dehydrate(bundle) 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/fields.py", line 729, in dehydrate return self.dehydrate_related(fk_bundle, self.fk_resource) 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/fields.py", line 557, in dehydrate_related return related_resource.get_resource_uri(bundle) 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/resources.py", line 784, in get_resource_uri return self._build_reverse_url(url_name, kwargs=self.resource_uri_kwargs(bundle_or_obj)) 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/resources.py", line 763, in resource_uri_kwargs kwargs.update(self.detail_uri_kwargs(bundle_or_obj)) 
  File "/Users/jonathan/virtualenvs/myproject/lib/python2.7/site-packages/tastypie/resources.py", line 2371, in detail_uri_kwargs kwargs[self._meta.detail_uri_name] = getattr(bundle_or_obj.obj, self._meta.detail_uri_name) AttributeError: 'RelatedManager' object has no attribute 'pk' "
  </code></pre>
  
  <h1>Edit</h1>
  
  <p>When I changed <code>followers_count = 1</code> to <code>followers_count = followers.count()</code> it gives me </p>
  
  <pre><code>"count() takes exactly one argument (0 given)"  error
  </code></pre>
  
  <h1>Edit</h1>
  
  <p>I finally realized that followers is a list not an object, so I changed my code a bit to</p>
  
  <pre><code>def connections(self,request,**kwargs):
      if request.user and request.user.is_authenticated():
          #Scribble Comments
          if request.GET.get('followers', ''):
              user = request.user
              followers = [connections.following for connections in user.followers.all()]
              users_id = [s.id for s in followers]
              users=User.objects.filter(id__in = users_id)
              users_count = users.count()
              users_list = {
              'users_count': users_count,
              'users' : users,
              'success': True,
              }
              return self.create_response(request, users_list)
          else:
              return self.create_response(request, { 'success': False, 'reason':'Wrong Query'})
      else:
          return self.create_response(request, { 'success': False, 'reason':'User not Logged in'})
  </code></pre>
  
  <p>Now I do get the output, but I get it in terms of objects, like</p>
  
  <pre><code>success: true,
  users: "[&lt;User: abc&gt;, &lt;User: test&gt;, &lt;User: abc2&gt;, &lt;User: test2&gt;]",
  users_count: 4
  </code></pre>
  
  <p>Instead of this, I want my object to show the email addresses and all of the user instead of just this object.</p>