in Education by
I have the following models: class Project(models.Model): name = models.CharField(max_length=300, unique=True) description = models.CharField(max_length=2000) class TemporaryUser(models.Model): username = models.CharField(max_length=400) project = models.ForeignKey( Project, on_delete=models.CASCADE, related_name='users' ) class QuestionSession(models.Model): project = models.ForeignKey( Project, on_delete=models.CASCADE, related_name='sessions', blank=True, null=True, default=None ) class Question(models.Model): # stores the main json object with all required information description = JSONField( max_length=10000, blank=True, null=True, default=None ) question_session = models.ForeignKey( QuestionSession, on_delete=models.CASCADE, related_name='questions', blank=True, null=True, default=None ) class Answer(models.Model): question = models.ForeignKey( Question, related_name='answers_list', on_delete=models.CASCADE) answer = models.CharField(max_length=500) answered_by = models.ForeignKey( TemporaryUser, on_delete=models.CASCADE, related_name='answers', blank=True, null=True, default=None ) In a nutshell, my app contains questions, session is a collection of questions, and a project is a collection of sessions. All users are unique per project. I can fetch all users and all answers within a specific project with the following: TemporaryUser.objects.all().filter(project__id=project_id) How can I do the same within a session? I don't really know how to do it, I need to filter users by session, is there a way how to do it with my relations? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Do you mean like: TemporaryUser.objects.filter(project__sessions__id=id)

Related questions

0 votes
    So in my project, I have a model Chat with many Messages. I want to have ChatSerializer with ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have a very long forms.py and I'd like to split it to smaller parts with as few as possible ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    I have a situation where i have a list of primary keys. And i need to filter(OR) a queryset ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have a situation where i have a list of primary keys. And i need to filter(OR) a queryset ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have a situation where i have a list of primary keys. And i need to filter(OR) a queryset ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Issue Recently I came across an issue with a client, that has many solutions, but none was easy. ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I need to create JWT token authentication, but I don't know how, could you explain me how to do ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    Suggestions needed for creating better and efficient search indexes for models having foreign key and many-to-many ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    In the section relation which of the following is used as a foreign key? (a) Course_id (b) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    Explain Q objects in Django ORM?...
asked Jul 2, 2021 in Technology by JackTerrance
0 votes
    In the above DDL command the foreign key entries are got by using the keyword (a) References (b) ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I have a model with two foreign keys to create many to many relationship - I am not using many to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I have a model with two foreign keys to create many to many relationship - I am not using many to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I am using Laravel 5.7 version. I got the below error for users_activations table while run the command ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I am using Laravel 5.7 version. I got the below error for users_activations table while run the command ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
...