TemplateSyntaxError: 'property' object is not iterable

44 views
Skip to first unread message

Chris Curvey

unread,
Dec 17, 2009, 4:12:20 PM12/17/09
to Django users
I have my class definition that looks like


class Foo:
def get_bars(self):
bars = []
# do something to collect bar instances
return bars
bars = property(get_bars)

in my template, I'd like to do something like this:

{% for bar in foo.bars %}
{{bar.snafu}}
{% endfor %}


But when I do that, I get "TemplateSyntaxError: 'property' object is
not iterable."

If I change it to {% for bar in foo.get_bars() %}, I get a
TemplateSyntaxError: could not parse the remainder"

If I change it to {% for bar in foo.get_bars %}, the template runs,
but it does not seem to be calling "get_bars"

How can I do what I'm trying to do? (Must I create a "regular" list
attribute and pre-populate it?)


Chris Curvey

unread,
Dec 18, 2009, 11:41:11 AM12/18/09
to Django users
Never mind. Me am a moron. Had a totally different programming error
elsewhere. It works as is it should.
Reply all
Reply to author
Forward
0 new messages