Oleg Korsak skrev:
> Hello. I have such code:
>
> tour_paginator =
> ObjectPaginator(Tour.objects.extra(where=['tours_country.id=tours_tour.country_id'],
> tables=['tours_country']).order_by('tours_country.name'), 20)
>
> tours = tour_paginator.get_page(page - 1)
>
> then in tours I have such set:
> [<Tour: fsgadfg>, <Tour: sgsd>, <Tour: dfghg>, <Tour: aaaa>, <Tour: sgsdf>]
>   
Just to make sure: Paginator.get_page returns a Queryset, not a set.

> then I'm doing this:
> for tour in tours:
>                       try:
>                               tour_dict[tour] = 
> TourDate.objects.filter(tour=tour)
>                       except TourDate.DoesNotExist:
>                               tour_dict[tour] = {}
>
> and THEN I have strange tour_dict contents (key sequece differs from tours):
>
> {<Tour: fsgadfg>: [], <Tour: aaaa>: [], <Tour: sgsd>: [], <Tour: sgsdf>:
> [], <Tour: dfghg>: []}
>   
Do you expect the keys in the dict to be in the same order they are
added? In that case you have misunderstood what a dict is.

So this seems like normal behavior if you have no matching TourDate
objects  (although the try/except is not necessary  - filter does not
throw DoesNotExist exceptions).


Nis

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to