I'm looking for some advice on what date-based generic view (or a
custom view) is best for this situation:

I have a model in my app called 'Meeting', which contains a
meeting_date field.  The meetings are monthly, so what I would like to
setup the URLs like this:
#1   /meetings/
#2   /meetings/2007/
#3   /meetings/2007/may/

For #2, I'm using the 'year_archive' generic view.

For #3, I'm thinking about using the object_detail generic view, but
I'm not sure how to use the abbreviated month name, rather than the
month number.  Any ideas?

#1 is the one that I really need help with.  I want #1 to always point
to the next meeting.  So if the next meeting_date (after today) is
2007-05-25 I want "/meetings/" to be the same as "/meetings/2007/
may/".  What is the best way to achieve this?  I'd prefer not to just
redirect to the appropriate month, but I would like to use the same
template for the meeting details in #1 & #3.  I came up with a few
options that might work:

a. Use the 'archive_index' generic view with num_latest=1 and
allow_future=True.  The downside to this is that archive_index will
return the meeting in the 'latest' list in the template context AND
meetings would have to be entered each month after the previous
meeting (so the latest meeting is correct).  This latter one is not a
big deal, because some of the fields in Meeting cannot be populated
until after the previous meeting.  Is there an easy way to alias the
one object in 'latest' so that it will work with my
meeting_detail.html template?

b. Use the 'object_detail' for #1, but pass it
Meeting.objects.latest('pub_date').id as the object_id.  This is what
I am currently using, but my question is, does this hit the database
twice?  Once to get the latest object, and then again in
'object_detail' view? SimiIar to (a), I think this one also suffers
from having to enter the meetings after the previous meeting.

c. Write a custom view that determines the next meeting and returns a
context similar to 'object_detail' so I can use the same template both
places.


Justin


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