Re: Must be a bug??? "ordering" error splits field
On Thu, 05 Apr 2007 14:10:05 +0800, Russell Keith-Magee wrote: > On 4/5/07, TaMeR <[EMAIL PROTECTED]> wrote: > >> class Meta: >> ordering = ('code') > > You have been bitten by a very common Python error: > > ('code') defines a string > ('code',) defines a tuple containing a single element, that is a string. Finally, ['code'] defines a list containign a single element. IMO it's much easier to type, and easier/less confusing for humans unfamiliar with Python to parse and understand. :) -- Sam Morris http://robots.org.uk/ PGP key id 1024D/5EA01078 3412 EA18 1277 354B 991B C869 B219 7FDB 5EA0 1078 --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Must be a bug??? "ordering" error splits field
Russell Keith-Magee napisaĆ(a): >> class Meta: >> ordering = ('code') > > You have been bitten by a very common Python error: > > ('code') defines a string > ('code',) defines a tuple containing a single element, that is a string. This is how strings works in Python, Ian Bicking even wrote a rant on this arguing that strings should not be treated as "normal" sequences. I cann't count how many times I was bitten by this "feature". ;) -- Jarek Zgoda "We read Knuth so you don't have to." --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Must be a bug??? "ordering" error splits field
== CODE == class Meta: ordering = ('code') == ERROR = $ python manage.py validate data.postcode: "ordering" refers to "c", a field that doesn't exist. data.postcode: "ordering" refers to "o", a field that doesn't exist. data.postcode: "ordering" refers to "d", a field that doesn't exist. data.postcode: "ordering" refers to "e", a field that doesn't exist. 4 errors found. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Must be a bug??? "ordering" error splits field
On 4/5/07, TaMeR <[EMAIL PROTECTED]> wrote: > class Meta: > ordering = ('code') You have been bitten by a very common Python error: ('code') defines a string ('code',) defines a tuple containing a single element, that is a string. The comma is required for parsing purposes to distinguish parentheses used for arithmetic binding, and parentheses used to define a tuple. Add a comma, and all will be good. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---