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_detail import object_detail

def random(request, provincia, numero, tipo):
    items = Scheda.objects.all()
    if provincia != None:
        items.filter(provincia__iexact=provincia)

    if tipo != None:
        items.filter(tipo__iexact=tipo)

    # Ordino a caso
    items.order_by('?')

    if numero != None:
        items = items[:numero]

    template = "random.html"

    return object_list(
        request,
        queryset = items,
        template_name=template,
    )

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net - Il mio sito personale
http://www.soasi.com - Sviluppo Software e Sistemi Open Source

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