No worries, that's always been one of the most awkward gotchas in python. It's made doubly so by the fact that iterating over a string gives more strings. On Jun 5, 2013 4:29 PM, "Cal Leeming [Simplicity Media Ltd]" < cal.leem...@simplicitymedialtd.co.uk> wrote:
> Hi Noah, > > Sorry yes I remember discussing this last time now, it wasn't until I hit > send that I remembered about 5 seconds after. > > I think I'm having a bit of a stupid day - my apologies. > > Cal > > On Wed, Jun 5, 2013 at 8:57 PM, Noah Kantrowitz <n...@coderanger.net>wrote: > >> >> On Jun 5, 2013, at 12:56 PM, Cal Leeming [Simplicity Media Ltd] wrote: >> >> > Hello, >> > >> > The following; >> > class Meta: >> > ordering = ('hostname') >> > >> > Results in; >> > amber.reseller: "ordering" refers to "h", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "o", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "s", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "t", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "n", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "a", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "m", a field that doesn't exist. >> > amber.reseller: "ordering" refers to "e", a field that doesn't exist. >> > >> > To fix this, I have to use; >> > class Meta: >> > ordering = ('hostname', ) >> > >> > However in python cli; >> > >> > salt1 foxx # python >> > Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) >> > [GCC 4.4.5] on linux2 >> > Type "help", "copyright", "credits" or "license" for more information. >> > >>> ['hostname'] >> > ['hostname'] >> > >>> lol = ['hostname'] >> > >>> lol[0] >> > 'hostname' >> > >>> lol[1] >> > Traceback (most recent call last): >> > File "<stdin>", line 1, in <module> >> > IndexError: list index out of range >> > >> > Could anyone please explain why Django is not treating this list/tuple >> properly? >> >> (x) isn't a tuple for the same reason (x+1)*4 isn't a tuple. (x,) is a >> tuple of one item. >> >> --Noah >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-developers+unsubscr...@googlegroups.com. >> To post to this group, send email to django-developers@googlegroups.com. >> Visit this group at >> http://groups.google.com/group/django-developers?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To post to this group, send email to django-developers@googlegroups.com. > Visit this group at http://groups.google.com/group/django-developers?hl=en > . > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers?hl=en. For more options, visit https://groups.google.com/groups/opt_out.