Re: Random objects in view

2007-10-05 Thread Alessandro Ronchi
2007/10/4, RajeshD <[EMAIL PROTECTED]>: > Remember that whenever you filter an existing queryset in order to > progressively develop a query, you get a new queryset. So, you need to > assign it back to a variable otherwise it's lost in the ether :) Ops :) -- Alessandro Ronchi Skype: aronchi ht

Re: Random objects in view

2007-10-04 Thread RajeshD
Hi Alessandro, Replace: items.filter(provincia__iexact=provincia) with items = items.filter(provincia__iexact=provincia) Similarly, replace items.filter(tipo__iexact=tipo) with items = items.filter(tipo__iexact=tipo) Remember that whenever you filter an existing queryset in order to progressiv

Re: Random objects in view

2007-10-04 Thread Alessandro Ronchi
2007/10/2, Tomas Kopecek <[EMAIL PROTECTED]>: > Maybe it is worth a ticket in trac. I tried, but it says: 500 Internal Server Error (Submission rejected as potential spam (Maximum number of posts per hour for this IP exceeded, Akismet says content is spam)) (I didn't send any other post) Your

Re: Random objects in view

2007-10-02 Thread oliver
This works for me. My model: class BannerPosition(models.Model): position = models.SmallIntegerField() banner = models.ForeignKey(BannerItem) class Meta: ordering = ('position', 'banner') def __str__(self): return '%s - %s' % (self.ba

Re: Random objects in view

2007-10-02 Thread Tomas Kopecek
Alessandro Ronchi napsal(a): > 2007/10/1, Tomas Kopecek <[EMAIL PROTECTED]>: > >> Now, I don't understand. What is the difference between these two cases? > > I don't know. If I put the random order before filter it works, if I > put it after filter it doesn't. > > Maybe it is worth a ticket i

Re: Random objects in view

2007-10-02 Thread Alessandro Ronchi
2007/10/1, Tomas Kopecek <[EMAIL PROTECTED]>: > Now, I don't understand. What is the difference between these two cases? I don't know. If I put the random order before filter it works, if I put it after filter it doesn't. -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net - I

Re: Random objects in view

2007-10-01 Thread Tomas Kopecek
Alessandro Ronchi napsal(a): > 2007/10/1, Tomas Kopecek <[EMAIL PROTECTED]>: > >> items = shuffle(items) > > > If I do that I get > > Exception Type: TypeError > Exception Value:object doesn't support item assignment > Oh, sorry, I forget that it works in place. It means you have to d

Re: Random objects in view

2007-10-01 Thread Alessandro Ronchi
2007/10/1, Tomas Kopecek <[EMAIL PROTECTED]>: > items = shuffle(items) If I do that I get Exception Type: TypeError Exception Value:object doesn't support item assignment The '?' works If I put it on objects.all.order_by('?') instead objects.all -- Alessandro Ronchi Skype: aronchi h

Re: Random objects in view

2007-10-01 Thread Tomas Kopecek
Alessandro Ronchi napsal(a): > I tried to create a random view with the code on the bottom. It > doesn't work, the order is always the same. > What's wrong? > items.order_by('?') ? Means, that order is undefined but not random with each call. If you want to randmize order, use this from ra

Random objects in view

2007-10-01 Thread Alessandro Ronchi
I tried to create a random view with the code on the bottom. It doesn't work, the order is always the same. What's wrong? # Create your views here. from adottami.adozioni.models import Scheda, Referente from django.views.generic.list_detail import object_list #from django.views.generic.list_deta