Hello

Im trying to create a webpage that displays several types of posts on
the front page, they all inherit from a basic Item class (say
BasicItem). On the front page I query for BasicItem.objects.all()
[0:20] and I want to pass them on to my template and let my template
render each item based on the actual subclass it is, using custom
templatetags that render each item. There does not exist a BasicItem
without a subclass. The subitems will be something like NewsItem,
LinkItem, ImageItem and share attributes like author, date_posted,
category, tags and so on..

the template would be something like:

{% for item in items %}
    {% ifequal item.subclass news %}
         {% rendernews item %}
     {% endif %}
     {% ifequal item.subclass link %}
          {% renderlink item %}
     {% endif %}
{% endfor %}

is there a different way to accomplish what im trying to do? or do i
need to check in my view function for which subclass that exists:
try:
    n = items.newsitem
except DoesNotExist:
    pass
try:
    l = items.linkitem
except DoesNotExist:
   pass

and then mark the item somehow so that the template can read it?

- gaute

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to