Wednesday, August 7, 2013

Re: Query Set and Output

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlICr84ACgkQuYLL1cDjHx1nTwCeOrkIWQc87GXTn+ftxhvWa12o
ZrkAn2bIh3QkKGY8b/pIWl69Ij4f0hj+
=puBe
-----END PGP SIGNATURE-----
Hi,

On Tue, 6 Aug 2013 20:19:01 -0700 (PDT) Muhammed TÜFEKYAPAN
<muhammedtfk@gmail.com> wrote:
> def home(request):
> output = Excuse.objects.order_by('?')[:1]

[:1] selects all elements from the beginning up to the first and
returns that list. true, its a list with only one member, but still a
list.

You want [0] to get the first element of the list/set that
Excuse.objects.order_by returns.

> 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:>]

Have fun,

Arnold

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate