Re: Django Query vs SQL query

2021-06-15 Thread Nikeet NA
use the related name on the staff model for project field with __ lookup as in class Staff(models.Model): . . project = foreignkey relationship (related_name='staffs') SO the query would be Projects.objects.filter(staffs__project_id=F('pk')) On Tuesday, 15 June 2021 at

Django Query vs SQL query

2021-06-15 Thread Eugene TUYIZERE
Team, I am a little bit confused: I have a table callect Projects and another called Staffs. I want a particular staff member to view only the project he/she has a role in. In the Staffs table I have a project foreign key project_id. But I am confused about how to construct the query. I think of