Re: Retrieving the values from query set
Hi Daniel ,Malcom Thanks for the reply That exactly was the solution I wanted On Mon, Aug 3, 2009 at 11:47 AM, Daniel Roseman wrote: > > On Aug 3, 7:03 am, Subramanyam Vemu wrote: > > Hi Malcom > > > > The values_list() returns a list of tuples whereas I am looking for a > simple > > list of the values > > > From the link Malcolm so helpfully provided: > > "If you only pass in a single field, you can also pass in the `flat` > parameter. If True, this will mean the returned results are single > values, rather than one-tuples." > > In other words, that's exactly what you want. > -- > DR. > > > -- Regards Subramanyam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
On Aug 3, 7:03 am, Subramanyam Vemu wrote: > Hi Malcom > > The values_list() returns a list of tuples whereas I am looking for a simple > list of the values > >From the link Malcolm so helpfully provided: "If you only pass in a single field, you can also pass in the `flat` parameter. If True, this will mean the returned results are single values, rather than one-tuples." In other words, that's exactly what you want. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
Hi Malcom The values_list() returns a list of tuples whereas I am looking for a simple list of the values On Mon, Aug 3, 2009 at 10:48 AM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Sun, 2009-08-02 at 21:59 -0700, bvemu wrote: > [...] > > Is there a django way of retrieving only the values as a list and not > > the fieldname > > Have a look at the values_list() method. That does what you are after. > > > http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields > > Regards, > Malcolm > > > > > -- Regards Subramanyam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Retrieving the values from query set
On Sun, 2009-08-02 at 21:59 -0700, bvemu wrote: [...] > Is there a django way of retrieving only the values as a list and not > the fieldname Have a look at the values_list() method. That does what you are after. http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Retrieving the values from query set
Hi In my project I want to store an integer as the username To randomly allocate a new username I need the list of available usernames (integer type list) I tried the following ways user_list=[] user_list=list(User.objects.values('username').order_by('username')) and when I try to print the values of list , it actually represents a string like ('fieldname':'value') >>> fun(user_list) {'username': u'1'} {'username': u'103'} {'username': u'11'} {'username': u'121'} {'username': u'13'} {'username': u'13421'} {'username': u'1342323221'} {'username': u'1342333661'} {'username': u'134563661'} Is there a django way of retrieving only the values as a list and not the fieldname Thanks in advance Subramanyam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---