Re: Query Set and Output

2013-08-07 Thread Arnold Krille
Hi, On Tue, 6 Aug 2013 20:19:01 -0700 (PDT) Muhammed TÜFEKYAPAN 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] t

Re: Query Set and Output

2013-08-07 Thread Muhammed TÜFEKYAPAN
"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.Cha

Re: Query Set and Output

2013-08-07 Thread abhijeet shete
Hi, If you tries to access values from list using slice it returns you the subset of list not a single value.The query *(*Excuse.objects.order_by('?')* )* from your view returns a list and you are trying to access values from that list using slice which in turn returns subset of list and becau

Re: Query Set and Output

2013-08-07 Thread Muhammed TÜFEKYAPAN
It looks like this: {{ output }} On Wednesday, August 7, 2013 6:58:17 AM UTC+3, Bulkan-Savun Evcimen wrote: > > Hi there, > > What does your template index.html look like ? > > Cheers > > http://bulkan-evcimen.com > > > On Wed, Aug 7, 2013 at 1:19 PM, Muhammed TÜFEKYAPAN > > > wrote:

Re: Query Set and Output

2013-08-06 Thread Bulkan
Hi there, What does your template index.html look like ? Cheers http://bulkan-evcimen.com On Wed, Aug 7, 2013 at 1:19 PM, 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.CharF

Query Set and Output

2013-08-06 Thread Muhammed TÜFEKYAPAN
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 = Excus