greetings,

i am attempting to fetch an object or all objects from a model and
make the data available at the template level via a custom template
tag.  it seems like you cannot return an object or all objects from
the template tag, as django throws the error: "object does not support
item assignment".  the template tag is quite simple:

from myproject.models import Project
from django.template import Library,Node

register = Library()

def build_project_list(parser, token):
    """
    {% get_project_list %}
    """
    return ProjectListObject()

class ProjectListObject(Node):
    def render(self, context):
        context['project_list'] = Project.objects.all()
        return ''

register.tag('get_project_list', build_project_list)

in the end, we would like pass a value to the template tag, like an ID
or slug, and receive back a specific object and make it availabe to
the template for display without using a for loop or anything.  for
example. project.name, project.slug, project.description, etc.

can anyone confirm for me that the custom template tags cannot return
an object?  if that is the case, what do folks do to display data in
such a way that does not depend on a view?

we are using django revision 4455, the latest svn build i think.

thanks,

steve


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to