+ 1

AttributeError: 'dict' object has no attribute 'objects' please help a friend

I have been on this for almost 12hrs and I don't seem to many any headway at finding what i am not doing right. Error message I keep getting is: Error Message k = fixture.objects.filter(api_football_fixture_id=id_fixture) AttributeError: 'dict' object has no attribute 'objects' views.py def get_score(request): if request.is_ajax() and request.POST: data = request.POST.get('date') score = get_scores(data) respond = {'message': 'operation successful'} return HttpResponse(json.dumps(respond), content_type='application/json') else: raise Http404 def get_scores(date): fixture = api_request(f'fixtures/date/{date}') for b in fixture['api']['fixtures']: if b['goalsHomeTeam'] is not None: home_score = str(b['goalsHomeTeam']) else: home_score = '' if b['goalsAwayTeam'] is not None: away_score = str(b['goalsAwayTeam']) else: away_score = '' extra_time = b['score']['extratime'] penalty = b['score']['penalty'] half_time = b['score']['halftime'] full_time = b['score']['fulltime'] match_status = b['status'] api_football_home_team_id =b['homeTeam']['team_id'] api_football_away_team_id =b['awayTeam']['team_id'] api_football_league_id = b['league_id'] id_fixture= b['fixture_id'] k = fixture.objects.filter(api_football_fixture_id=id_fixture) print(k)

18th Nov 2019, 2:40 PM
Kayode Adetayo
Kayode Adetayo - avatar
4 Respostas
+ 2
Mirielle🐶 [Inactive] i am able to make api calls with data value. just having issue with the queryset. i tried the suggestion. i am still getting the same error. thanks
18th Nov 2019, 3:46 PM
Kayode Adetayo
Kayode Adetayo - avatar
+ 1
Mirielle🐶 [Inactive] I am finally able to trace it. one of the variables shares same name with my model. Everything works fine now. Thanks
20th Nov 2019, 6:07 AM
Kayode Adetayo
Kayode Adetayo - avatar