>> your __str__ returns a function...you omitted the call to that >> function: >> >> def __str__(self): >> return self.name() > > Ah - knew it would be obvious. Thanks. Simple typo on my part, I've just > split the name field in two, so it used to be a property.
Fortnately, Python makes this very easy with the built-in property() call: class MyModel(Model): surname = CharField(...) forenames = CharField(...) def _get_name(self): return self.forenames + ' ' + self.surname name = property(fget=_get_name) This will expose "name" as an attribute such that you don't have to call it. Having done my share of Java, this ability to write code as if everything is just an attribute, then go back later and retrofit get/set behaviors with minimal fuss is a blessing. Thus, there's almost never a Java-esque need in Python to make mountains of getters/setters to future-proof your code in case you _might_ want to _maybe_ make access to an attribute be done programatically. -tim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---