How to use 'raw query django' in Python

Every line of 'raw query django' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
174def test_raw_sql_query(self):
175 "Testing raw SQL query."
176 cities1 = City.objects.all()
177 point_select = % 'point'
178 cities2 = list(City.objects.raw(
179 'select id, name, %s as point from geoapp_city' % point_select
180 ))
181 self.assertEqual(len(cities1), len(cities2))
182 with self.assertNumQueries(0): # Ensure point isn't deferred.
183 self.assertIsInstance(cities2[0].point, Point)

Related snippets