"outout = Excuse.objects.order_by('?')[0]"

This works well.

Thank you.

On Wednesday, August 7, 2013 6:19:01 AM UTC+3, Muhammed TÜFEKYAPAN wrote:
>
> Hello everyone,
>
> I write a basic model in django 1.5.1
>
> My model is looks like this:
> class Excuse(models.Model):
> text = models.CharField(max_length=300)
>
> def __unicode__(self):
> return self.text
>
> And i have a basic function to get random excuse from this model.
>
> def home(request):
>     output = Excuse.objects.order_by('?')[:1]
>     template = loader.get_template('index.html')
>     context = {'output': output}
>     return HttpResponse(output)
>
> If i write my view looks like above everything works well. I get a random 
> excuse and write it on the page. But when i change this like this:
>
> def home(request):
>     output = Excuse.objects.order_by('?')[:1]
>     template = loader.get_template('index.html')
>     context = {'output': output}
>     return render(request, 'index.html', context)
>
> I get output like this: [<Excuse: BlaBla>]
> i just want to blabla section and how i get away from  [<Excuse:>]
>
>
> Thanks for all!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to