title: select_related() and many to many fields with ajax (Django)
body: <p>I have a simple view that I want to respond to both ajax and regular HTTP requests. Simplified, it looks like this:</p>
  
  <pre><code>def tag_search(request, tag):
  
      items = Item.objects.filter(tags__tagname__exact=tag)
  
      if request.is_ajax():
  
          return HttpResponse(serializers.serialize('json', items), mimetype='application/json')
  
      else:
  
          return render_to_response('mytemplate.html', locals())
  </code></pre>
  
  <p>The problem is that it isn't returning the values of the many to many relationships - just a list of the primary keys like:</p>
  
  <pre><code>[1, 2, 5]
  </code></pre>
  
  <p>I understand that I can't use select_related() to follow many to many relationships - can anyone provide me with a best practice for passing that information back, or an example?</p>