Skip to content

Instantly share code, notes, and snippets.

@nigma
Last active October 11, 2015 01:48
Show Gist options
  • Save nigma/3784395 to your computer and use it in GitHub Desktop.
Save nigma/3784395 to your computer and use it in GitHub Desktop.
PostgreSQL field type casting in Django subqueries
User.objects.filter(
pk__in=Follow.objects.filter(
user=self.user,
content_type=ContentType.objects.get_for_model(User)
).extra(select={"user_ids": "object_id::integer"}).values_list("user_ids")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment