I'm attempting to iterate through each "User" and get a list of
"Events" for each user. I feel that my code below is sound, but Django
doesn't agree (I'm not using a template because I'm just doing a proof
of concept at this point, hence the direct HttpResponse(eventList)).
I'm getting this error:
MultipleObjectsReturned at /stats/
get() returned more than one Events -- it returned 102! Lookup
parameters were {'user': Decimal('230091')}
Here's the offending views.py:
def stats(request):
people = Users.objects.all()
eventList = []
for person in people:
try:
events = Events.objects.get(user=person.user_id)
for event in events:
eventList.append(events)
except Events.DoesNotExist:
pass
return HttpResponse(eventList)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---