On Thu, Dec 9, 2010 at 14:13, Lachlan Musicman <data...@gmail.com> wrote:
> On Thu, Nov 25, 2010 at 16:00, Christophe Pettus <x...@thebuild.com> wrote:
>>
>> On Nov 24, 2010, at 8:13 PM, Lachlan Musicman wrote:
>>> Thanks Christopher. I've never done raw SQL in Django before. This may
>>> seem like a silly follow up question, but is it standard practice to
>>> put the relevant code, as described by the documentation
>>> (http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly
>>> ) into views.py?
>>
>> Oh, and: Another very logical place to put this is in a custom Manager 
>> subclass for the relevant Model; there's documentation on that usage in the 
>> docs:
>>
>>        
>> http://docs.djangoproject.com/en/1.2/topics/db/managers/#adding-extra-manager-methods
>>
>
> I've successfully got the data I was after, and I've even got it into
> the template with success - thankyou!
>
> The problem I now have is that the data returned has the format:
>
> language,number,percent
>
> where language = short language code.
>
> In the template I'd like to represent language in it's long form, but
> am having all types of trouble getting it to do so. I have the longs
> in a dictionary in my models.py, in my views.py I've created a smaller
> dict of long_langs, but how do I then match them in the template?
>
> Here's some of my template attempts:
>
> these proved that the data is coming through to the template
> {{ target_stats }}
> {# {{ long_langs  }} #}
> {#  {{ lang_dict }} <br /> #}
>
> These loops didn't work (for obvious reasons...)
>
>  {% for language, number, percent in target_stats %}
>        {{ long_lang.foorloop.counter }} {{ number }} {{ percent }} <br />
>  {% endfor %}
>
> and
>
>  {% for language, number, percent in target_stats %}
>        {{ lang_dict[language] }} {{ number }} {{ percent }} <br />
>  {% endfor %}
>
> there have been a few other attempts - mostly riffs on those
> themes...I even tried a
> for(for(if))) but nothing came out.
>
> I'm confused about how to get this right


Ignore - I got this within 5 minutes of posting. God.damn.it.



-- 
"... imagine a puddle waking up one morning and thinking, 'This is an
interesting world I find myself in - an interesting hole I find myself
in - fits me rather neatly, doesn't it? In fact it fits me
staggeringly well, must have been made to have me in it!' This is such
a powerful idea that as the sun rises in the sky and the air heats up
and as, gradually, the puddle gets smaller and smaller, it's still
frantically hanging on to the notion that everything's going to be
alright, because this world was meant to have him in it, was built to
have him in it; so the moment he disappears catches him rather by
surprise."
Douglas Adams

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to