0

I have few things to ask for custom queries in Django

  1. DO i need to use the DB table name in the query or just the Model name
  2. if i need to join the various tables in raw sql. do i need to use db field name or model field name like

Person.objects.raw('SELECT id, first_name, last_name, birth_date FROM Person A inner join Address B on A.address = B.id ')

or B.id = A.address_id

1 Answer 1

3

You need to use the database's table and field names in the raw query--the string you provide will be passed to the database, not interpreted by the Django ORM.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.