Ken Kennedy wrote: > Yep...I'm actually dealing with that today. It's instead only returning > a list of datetimes that represent the months within that year that > contain objects. (ie, if it's a blog, and you have posts in Oct-Dec of > 2005, then the date_list would contain datetime objects for Oct 1st, > Nov 1st, and Dec 1st, representing the months that have objects). I > guess the assumption within the framework here is that the year is a > stepping stone to the month...too many objects at the year level, so > they just give you the months to build URLs from to get to the > archive_month view easily. I'm not thrilled with it either. *grin*
Of course, that's when you break out and write your own view. (I needed to write my own views anyway because I needed a full calendar and the archive_* views filter out "future" dates anyway, though.) For instance, I thought it would be cool to have "major" object float to this year page, so I wrote that as view, and that is based wholly on a model-specific judgment that can't easily be expressed in a generic view. On the other hand, the code I just wrote to yield a month calendar grid, instead of just a list of objects, is a bit more useful/generic. > I have a related issue...now that I have the datetime date_list of > months, I try to iterate over it, and it's being treated as a string: > > print date_list gives me : [datetime.datetime(2005, 1, 1, 0, 0), > datetime.datetime(2005, 3, 1, 0, 0)] > > for month in date_list, though, gives me > 'str' object has no attribute 'month' > > So it's treating date_list as a string, rather than a iterable list. I > know that "free" access to the datetime module is being removed in > magic-removal, but I'm at rev 1811...have I somehow gotten caught in > betwixt something? How/where do I import datetime; I'm using a generic > view.! Or is there something I can add in the template that I'm missing > (or something else silly that I'm missing *grin*) You shouldn't have to import anything inside a template or generic view that either don't already have access to. Also, the "free" access didn't affect templates to begin with, it was something that model classes got. As for your error, it sounds like Django may be misleading you, here. The error templates don't generally highlight the correct line for variable lookups( {{ }} ), and instead highlight the containing template tag ( {% %} ). It sounds like somewhere below you are trying to do {{ month.month }} Keep in mind to iterate the months you need something like: {% for month in date_list %} {{ month|date:"F" }} {% endfor %} The date filter being the only way to get information from a date time. -- --Max Battcher-- http://www.worldmaker.net/ "History bleeds for tomorrow / for us to realize and never more follow blind" --Machinae Supremacy, Deus Ex Machinae, Title Track --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers -~----------~----~----~----~------~----~------~--~---