0

Hello Everyone Can anyone Help Me ragarding this? I want to convert a django filter query to raw sql query and below is the example Django Query

Product.objects.filter(name__icontains=self.request.GET.get('product_name'))

Is there a online method or some other way that i can convert it to RAW sql Query for my postgresql database or any database. I dont know that much about database queries Ill be thankful if someone could help.

Chip
  • 71
  • 1
  • 10

1 Answers1

0

You can see SQL that will be run from any Django queryset by converting the .query attribute to a string

queryset = Product.objects.filter(name__icontains=self.request.GET.get('product_name'))
print(str(queryset.query))
Iain Shelvington
  • 31,030
  • 3
  • 31
  • 50