I'm trying to shove some custom query sets into extra context for
something like 5 generic view items. One of the QSs finds all news
items that are marked as 'hot' and is used to display those item (if
they exist) in a small list on any page along with whatever content is
intended for the main column. The QS can apparently return a
DoesNotExist exception instead of a query set, since there 'hot'
objects do not necessarily exist. How would I go about handling this?

I was thinking of doing something like this in URLconf:

def get_hot_items():
    try:
        Post.objects.get_hot()
    except DoesNoExist:
        return []

and in extra_context:

extra_context = {
    ....
    hot_news_items: get_hot_items
    }

What do you think? Is this the correct way of doing things, or there
is a shortcut / better way? (I'm not currently near my own PC so I
can't test it, but I thought I'd collect some feedback before I get a
chance to test this.)
--~--~---------~--~----~------------~-------~--~----~
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