0

I have a python data dictionary that I am using to do some date comparisions. However when I loop through it I can't figure out how to access the DailyPlannerRequest value. I have tried doing a request.DailyPlannerRequest but the error that comes back is 'datetime.date' object has no attribute 'DailyPlannerRequest'. I've read a bit about trying to convert this dictionary value but can't find anything helpful. I am trying to do a loop and query a filter value and compare it to this data dictionary value.

I'm trying to do something like....

        if request.day == day and event.daily_planner_request_name == request.DailyPlannerRequest :

I've done this lots of times before but the complication here is that one is a queryset and the other is a dictionary value that I'm trying to get to compare.

I've played a bit with the approach documented here Accessing dict keys like an attribute?

But can't seem to figure this out.

enter image description here

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Steve Smith
  • 1,019
  • 3
  • 16
  • 38
  • 1
    Did you try loop: `for key, value in dict.items()` where your key would be datetime.date and value [] and please shere code not images. – Waldemar Podsiadło Aug 07 '22 at 18:49
  • @WaldemarPodsiadło Thank you for the response. I'll try that....I was showing my console output for reference....In this case wasn't code perse...I normally always provide code where appropriate. Thanks again for the suggestion. – Steve Smith Aug 07 '22 at 19:06

1 Answers1

0

@Waldemar Podsiadlo answered this one. The answer he provided helped me with my troubleshooting...for key, value in dict.items()

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40
Steve Smith
  • 1,019
  • 3
  • 16
  • 38