On 09-12-13 7:35 PM, John Handelaar wrote:
> My problem, and question:  how on earth can I instead spit this data
> out with years as the column headers and the categories as rows,
> instead?  There are far more categories of data than there are years
> of data, and what I have now simply won't fit into the horizontal
> space of the average browser window.

If your template is getting too complex or you can't see how to figure 
it out, restructure your content in your view to make your template 
easier. Python's good at doing that, the templating language isn't.

So if your data was:

[ "year": "2009", "data": expenserow1 ],
[ "year": "2008", "data": expenserow2 ],

You would be able to do simply, for head:

<tr>{% for row in expenses %}<th>{{ row.year }}</th>{% endfor %}</tr>

For rows:

{% for row in expenses %}
        <tr><td>{{ row.data.salary }}</td><td>{{ row.data.travel }}</td></tr>
{% endfor %}

And so on.

> Tips (which don't involve creating a dozen new
> semantically-much-less-meaningful models) gratefully received...

You could get the models to work the way you want, but one tip is to 
considering getting the data just the way you want to work easily in 
your template and that's just (hopefully) simple Python data structure 
manipulation.

Good luck fitting all those 000's in for their expenses for the duck 
pond and the adult movies ;)
-- 
   Andy McKay, @clearwind
   Whistler conference: http://clearwind.ca/djangoski/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
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