> AssertionError: {'Southeast': [<Event: A big event in September>],
> 'Northeast':
> [<Event: One more Test Event>], 'Pacific': [<Event: Big Pacific
> show>],
> 'Southwest': [<Event: Southwest Event>]}
[aside: please use edited-down inline posting conventions rather
than top-posting to make the conversation easier to follow]
I'm not sure if just using "region" is being considered a unique
item (or being overly unique). Try changing this line:
region = event.club.region
to
region = str(event.club.region)
or
region = event.club.region.name
or something that is string. For debugging purposes, you can
also adjust the code to look something like
events = {} # or SortedDict if order matters
+ new_lists = 0
+ appended_lists = 0
for event in future_events: # one DB hit here
- region = event.club.region
+ region = str(event.club.region)
+ if region in events:
+ appended_lists += 1
+ else:
+ new_lists += 1
ev_list = events.get(region, [])
ev_list.append(event)
events[region] = ev_list
+ assert False, '%i created, %i updated, %i total' % (
+ new_lists, appended_lists, len(future_events))
This should give an idea as to how many regions are added to the
dictionary, and how many resultant lists should have been updated
(the two tallies should sum to the len() of the future_events).
You can try it with and without the "region =
str(event.club.region)" change and see if they're different.
-tim
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---