journal
all ![]() | Rob is 20,118 days old today. |
Oct 2010 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Dec 2010 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 2009 jan feb mar apr may jun jul aug sep oct nov dec
2011 jan feb mar apr may jun jul aug sep oct nov dec |< << more >> >| |
Entries this day: Lou_unplugged emails lin to_do_to_mo_ro Lou unplugged 5:43pm JST Friday 12 November 2010 (day 14842) Though I will readily admit I am low on fundage, I have decided to go see Loustar AKA's show again tonight at The Pink Cow... I was swayed by the video put up by Jason, Loustar Live in Tokyo, in which I can see and hear clearly how much fun it was!! Whooo!! I'm *reallly* going to try to see Lin tonight as well, if at all possible. I think she's going to see SAW 7 3D with a friend who really likes the series of movies. I've never seen any of them, but Lin said the story is actually quite intriguing. Hmmmmm. 11:00pm JST Friday 12 November 2010 (day 14842) In the end, she didn't get to play, which sucks, but Lin and I got to hang out with her cuddly close at The Pink Cow, which ruled! She'll be in Tokyo for a while longer (two more weeks?) so I'll certainly get to see her perform again. Awesome. permalinkemails 5:49pm JST Friday 12 November 2010 (day 14842) Hey Travis! Thanks for asking again about django; I'm a bit sidetracked, but I have been composing a question for you... I wanted to get some code up on github first so I could show you examples. Right now, though, you can see the data which I'm trying to process at http://dev.pekoneko.com/statistics/ Quick version of my question: how do I display QuerySets that may need some special display depending on the values in the rows? Templates aren't really smart enough, it seems. Maybe by including templates within templates, but even then, how does the parent template know *when* to include the child? Speaking in general terms, I am retrieving a QuerySet which returns many rows from many one-to-many relationships. A --> a A --> b A --> c B --> d B --> e C --> g C --> i When I display these, I want to show the one as a title, and then the many related records below that <div class='title'>A</div> <div >a</div> <div >b</div> <div >c</div> <div class='title'>B</div> <div >d</div> <div >e</div> <div class='title'>C</div> <div >g</div> <div >i</div> BUT, the template doesn't have the logic to keep track of last item.title to see if it's different than current item.title and display the new title as a title instead of just div. So (getting to more specifics) I've written a function called beautify() which takes the QuerySet and returns an array of dictionaries (correct term??) that looks something like this when printed without processing: {'count': 2L, 'four_digits': u'3455'} {'answer': u'(3+4-5)*5'} {'count': 3L, 'four_digits': u'0019'} {'answer': u'0-0+(1+9)'} {'answer': u'0*0+(1+9)'} {'answer': u'(0+0)+(1+9)'} {'answer': u'(0-0)+(1+9)'} {'answer': u'(0*0)+(1+9)'} {'answer': u'(0+0+1)+9'} {'answer': u'(0-0+1)+9'} {'answer': u'(0*0+1)+9'} {'answer': u'0+(0+1+9)'} {'answer': u'0-(0-1-9)'} {'count': 1L, 'four_digits': u'4444'} {'answer': u'none'} {'count': 1L, 'four_digits': u'2828'} {'answer': u'2+8*2-8'} {'answer': u'2-8+2*8'} {'answer': u'2*8+2-8'} {'answer': u'(2-8)+2*8'} {'answer': u'(2*8)+2-8'} {'answer': u'2+(8*2)-8'} {'answer': u'2-8+(2*8)'} {'answer': u'2*8+(2-8)'} {'answer': u'(2-8)+(2*8)'} {'answer': u'(2*8)+(2-8)'} The lines with 'count' and 'four_digits' are basically the title lines, and the 'answer' lines are the items that should be printed below the titles. I have a sinking feeling that the templates can't even do enough logic to process this elegantly. I could possibly use {% is_equal %} but 'four_digits' is not always defined, so it's clearly a flawed process of outputting ... I think I should search Google for [process queryset before template] or something like that.. for now this email will just be in my journal; I can't bear to bother you much before I've tried a bit harder on it. :-)permalink lin 12:25am JST Saturday 13 November 2010 (day 14843) Lin drove me to Yokohama station, something that has become a bit of a ritual for us. We'll talk talk talk talk and then drop me off at the rotary. permalinkto do to mo ro 12:57am JST Saturday 13 November 2010 (day 14843)
prev day next day |