title: heroku, postgreSQL, django, comments, tastypie: No operator matches the given name and argument type(s). You might need to add explicit type casts
body: <p>I have a simple query on django's built in comments model and getting the error below with heroku's postgreSQL database:</p>
  
  <pre><code>DatabaseError: operator does not exist: integer = text LINE 1: 
  ... INNER JOIN "django_comments" ON ("pi ns_pin"."id" = "django_...
                                                           ^
  HINT:  No operator matches the given name and argument type(s). 
  You might need to add explicit type casts.
  </code></pre>
  
  <p>After googling around it seems this error has been addressed many times before in django, but I'm still getting it (all related issues were closed 3-5 years ago) . I am using django version 1.4 and the latest build of tastypie.</p>
  
  <p>The query is made under orm filters and works perfectly with my development database (sqlite3):</p>
  
  <pre><code>class MyResource(ModelResource):    
  
      comments = fields.ToManyField('my.api.api.CmntResource', 'comments', full=True, null=True)
  
      def build_filters(self, filters=None):
          if filters is None:
              filters = {}
  
          orm_filters = super(MyResource, self).build_filters(filters)
  
          if 'cmnts' in filters:
              orm_filters['comments__user__id__exact'] = filters['cmnts']
  
  class CmntResource(ModelResource):
      user = fields.ToOneField('my.api.api.UserResource', 'user', full=True)
      site_id = fields.CharField(attribute = 'site_id')
      content_object = GenericForeignKeyField({
          My: MyResource,
      }, 'content_object')
      username = fields.CharField(attribute = 'user__username', null=True)
      user_id = fields.CharField(attribute = 'user__id', null=True)
  </code></pre>
  
  <p>Anybody have any experience with getting around this error without writing raw SQL?</p>