Re: getting tuples from http request.GET
You could use the same variable name on the querystring and call: request.GET.getlist For example, on a select multiple field ou checkbox John Mobile & Web developer +55(12)98864-1594 > On Mar 8, 2015, at 00:01, Sunil Sawant wrote: > > Thanks Collin, you cut out the crap from from my code. Simple is beautiful :) > >> On Friday, March 6, 2015 at 5:11:45 PM UTC-8, Collin Anderson wrote: >> Hi, >> >> Normally query arguments are separated by &. If you're able to send the data >> like this: >> >> https://mydesktop.com/validator?hostname1=host1.example.com&location1=ca&ip1=2.2.2.2&hostname2=host2.example.com&location2=wa&ip2=3.3.3.3 >> >> Then you could do something like: >> >> data = [] >> i = 0 >> while True: >> i += 1 >> try: >> data.append((request.GET['hostname%s' % i], request.GET['location%s' >> % i], request.GET['ip%s' % i])) >> except KeyError: >> break >> >> Collin >> >>> On Wednesday, March 4, 2015 at 7:57:17 PM UTC-5, Sunil Sawant wrote: >> >>> Hi Guys, >>> >>> Pretty new to Django, but used it blindly and works wonders. But here is a >>> situation I am blocked at now for a new project >>> >>> I request.GET the following URL >>> >>> https://mydesktop.com/validator?hostname1=host1.example.com,location1=ca,ip1=2.2.2.2,hostname2=host2.example.com,location2=wa,ip2=3.3.3.3 >>> >>> Am using request.GET I want to get the output in a tuple or hash form as: >>> >>> [{host1.example.com:[ca,2.2.2.2]},{host2.example.com:[wa,3.3.3.3]}] >>> >>> >>> >>> Once I have this data I can process it further. >>> Please help > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/fbdcea09-29e8-4765-9f36-47539a387dbb%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA17689D-B76E-4ADA-8DBC-854180D7A7D6%40me.com. For more options, visit https://groups.google.com/d/optout.
Re: getting tuples from http request.GET
Thanks Collin, you cut out the crap from from my code. Simple is beautiful :) On Friday, March 6, 2015 at 5:11:45 PM UTC-8, Collin Anderson wrote: > > Hi, > > Normally query arguments are separated by &. If you're able to send the > data like this: > > > https://mydesktop.com/validator?hostname1=host1.example.com&location1=ca&ip1=2.2.2.2&hostname2=host2.example.com&location2=wa&ip2=3.3.3.3 > > Then you could do something like: > > data = [] > i = 0 > while True: > i += 1 > try: > data.append((request.GET['hostname%s' % i], request.GET[ > 'location%s' % i], request.GET['ip%s' % i])) > except KeyError: > break > > Collin > > On Wednesday, March 4, 2015 at 7:57:17 PM UTC-5, Sunil Sawant wrote: > >> Hi Guys, >> >> Pretty new to Django, but used it blindly and works wonders. But here is >> a situation I am blocked at now for a new project >> >> I request.GET the following URL >> >> >> https://mydesktop.com/validator?hostname1=host1.example.com,location1=ca,ip1=2.2.2.2,hostname2=host2.example.com,location2=wa,ip2=3.3.3.3 >> >> Am using request.GET I want to get the output in a tuple or hash form as: >> >> [{host1.example.com:[ca,2.2.2.2]},{host2.example.com:[wa,3.3.3.3]}] >> >> >> >> Once I have this data I can process it further. >> Please help >> >> >> >> >> >> -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fbdcea09-29e8-4765-9f36-47539a387dbb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: getting tuples from http request.GET
Hi, Normally query arguments are separated by &. If you're able to send the data like this: https://mydesktop.com/validator?hostname1=host1.example.com&location1=ca&ip1=2.2.2.2&hostname2=host2.example.com&location2=wa&ip2=3.3.3.3 Then you could do something like: data = [] i = 0 while True: i += 1 try: data.append((request.GET['hostname%s' % i], request.GET['location%s' % i], request.GET['ip%s' % i])) except KeyError: break Collin On Wednesday, March 4, 2015 at 7:57:17 PM UTC-5, Sunil Sawant wrote: > Hi Guys, > > Pretty new to Django, but used it blindly and works wonders. But here is a > situation I am blocked at now for a new project > > I request.GET the following URL > > > https://mydesktop.com/validator?hostname1=host1.example.com,location1=ca,ip1=2.2.2.2,hostname2=host2.example.com,location2=wa,ip2=3.3.3.3 > > Am using request.GET I want to get the output in a tuple or hash form as: > > [{host1.example.com:[ca,2.2.2.2]},{host2.example.com:[wa,3.3.3.3]}] > > > > Once I have this data I can process it further. > Please help > > > > > > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/438392a2-4d17-4e91-bfe9-27ae17e2a80a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
getting tuples from http request.GET
Hi Guys, Pretty new to Django, but used it blindly and works wonders. But here is a situation I am blocked at now for a new project I request.GET the following URL https://mydesktop.com/validator?hostname1=host1.example.com,location1=ca,ip1=2.2.2.2,hostname2=host2.example.com,location2=wa,ip2=3.3.3.3 Am using request.GET I want to get the output in a tuple or hash form as: [{host1.example.com:[ca,2.2.2.2]},{host2.example.com:[wa,3.3.3.3]}] Once I have this data I can process it further. Please help -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a6bd8dad-23fa-43f4-a3b2-c6cc8efafc7a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.