On Mon, May 11, 2009 at 4:29 PM, Tom <[email protected]> wrote:

>
> Thank you Michael,
>
> Can you explain me the "Clean" way to do that ?
>

Sure, you create a view (or use a generic view) that calls a template and
has one of your models like so:

from django.shortcuts import render_to_response
from yourapp.models import YourModel

def yourview(request):
    m = YourModel.objects.order_by('?')[0]
    return render_to_response('yourtemplate.html', { 'object' : m})

and your template would then have a simple link like so

<a href="{{ object.url }}">{{ object.title }}</a>

Simple. I hope that helps,

Michael

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