On Sun, 2008-02-10 at 10:33 -0500, Prof. William Battersea wrote: [...] > > I had a Model called Gallery, which had a ManyToManyField pointing to > a Model called Location. In location, I had set my __str__ method to: > > return " / ".join(str(v) for v in self.location if not v == "")
There are multiple problems here. Firstly, you want to be iterating over self.location.all(), not self.location. The self.location attribute is a ManyRelatedManager instance (which you really don't care about at all, trust me -- the point is, it's not something iterable). You use self.location as a queryset, essentially, so you can filter it, etc. Secondly, 'v' will then be a Location instance. So comparing it to "" is not going to do anything sensible. Possibly you want to be testing if str(v) != "" instead (comparing apples to apples, rather than elephants to apples). I'm still not entirely sure why this problem led to the error you reported, but it's not impossible to imagine. I would have expected you to get some kind of error like "ManyRelatedManager is not iterable", though. *shrug* Regards, Malcolm -- No one is listening until you make a mistake. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---