Hi,

> i have a simple question here, i've been trying to found the answer
> but somehow i got confused if this is wheter possible or not:


 it's always possible, just a matter of time and effort (and cost) ;-)

> I have two django models, movies and books , i want to get all the
> objects from both models and order them by date, getting result_set
> that
> might look like this:
>
> movie1
> movie2
> book1
> movie3
> book2

It depends a bit on the context (i.e. do you really want all objects
or just the most recent ones?). I'll only provide a few hints.

 - convert whatever you need to combine into lists. You may want all
or just latest 20 objects, i.e

>>> movies = Movie.objects.all()
>>> books = Book.objects.all()

or

>>> movies = Movie.objects.all().order_by('-id')[:20]
>>> books = Book.objects.all().order_by('-id')[:20]

then

>>> my_objects = list(movies).extend(list(books))

then

>>> my_objects.sort(key=...)  #  see http://wiki.python.org/moin/HowTo/Sorting

Hope this helps

   Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to