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?)


--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to