On Mon, Aug 8, 2011 at 12:14 PM, Josh <jos.carpente...@yahoo.com> wrote:
> > {% get_related_entries weblog.entry 5 from object.categories as > related_entries %} > > I found that out already. Now I'm pretty sure the problem is in the > rendering. As far as I can tell ( I don't know how to test template tags in > a shell ) I get a list of the names of the categories back. > > > - When I try to iterate the list, I get the 'Caught TypeError while > rendering: 'Variable' object is not iterable' error. > - When I don't iterate the variable I get the 'Caught TypeError while > rendering: int() argument must be a string or a number, not 'Variable' > - When I try to append queries (with Q or the normal way, because I > need an OR relation), that works neither. > > It sounds like you're not resolving the variable at all in your render method -- When you construct the template node, you work with Variable objects, which represent the context variable as it exists in the template source (eg, html). At the point where you actually render your output, you want to resolve that Variable, so that the template framework actually determines what the contents of that variable should be, given the current context. The example at https://docs.djangoproject.com/en/1.3/howto/custom-template-tags/#passing-template-variables-to-the-tag shows how it should be done. Construct a Variable object in node.__init__(), and use variable.resolve(context) in node.render() Ian > > - > > ??? I don't know how to continue. I'm thinking now of solving this outside > Django in a 'normal' python script (somehow) and pass the values as > formatted html back to the template. That shouldn't be necessary I think. > I'm sure I'm overlooking a very fundamental issue with templates and > templatetags, but I just don't get it (yet). > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/yYKP0Xoz9XkJ. > > To post to this group, send email to django-users@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. > -- Regards, Ian Clelland <clell...@gmail.com> -- 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 django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.