in Education by
I have two tables in my database which are relevant for this problem: exercise_state with following fields: | id | intensity_level | progress | exercise_id | user_id | current_date | user_rating | auth_user with following fields: | id | password | last_login | is_superuser | username | first_name | last_name | email | is_staff | is_active | date_joined | Right now I am fetching some data in my view as follows: def get_specific_exercise_finish_count(request, exerciseId): # Number of users who completed a specific exercise specific_exercise_finish_count = Exercise_state.objects.filter(exercise_id=exerciseId, intensity_level=7).count() data = {} data['count'] = specific_exercise_finish_count return JSONResponse(data) Now I want to filter those results further for specific set of usernames i.e. usernames those starts with 'yg_' (I have two sets of usernames registered in my system one group starts with 'yg' and the other with 'yg_'). As username is not a field of exercise_state, I am not sure how to proceed. How can I achieve this? 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
I solved it with following code of piece, see the extra part in filter statement: def get_specific_exercise_finish_count_memoryGames(request, exerciseId): # Number of users who completed a specific exercise specific_exercise_finish_count_memoryGames = Exercise_state.objects.filter(exercise_id=exerciseId, intensity_level=7, user__username__startswith='yg_').count() data = {} data['count'] = specific_exercise_finish_count_memoryGames return JSONResponse(data)

Related questions

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
    I'm traying to make some tests for an api here is the code: tests.py class APITest(APITestCase): ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I'm stuck with this error for one on my app : Traceback (most recent call last): File "manage.py ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have configured my timezone in settings, as America/Guatemala and I have some datetime fields in my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I want to create a form that shows 2 different textboxes with a minimum and a maximum value of my ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I have been researching how to create django react application and the best way to go about implementing it ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I have been researching how to create django react application and the best way to go about implementing it ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 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 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
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    So, I started learning to code in Python and later Django. The first time it was hard looking at tracebacks and ... your Django code? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    In the Django model QuerySets, I see that there is a __gt and __lt for comparative values, but is there a __ne/!= ... (a=true, x__gt=5) Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
...