Re: Django Template Hyphenated Keys

2009-02-17 Thread bfrederi
I decided to write a template tag for my purposes. It's kind of specific to a dictionary within a dictionary, but here is what I created: from django import template register = template.Library() def get_term_value(parser, token): try: # split_contents() knows not to split quoted st

Re: Django Template Hyphenated Keys

2009-02-17 Thread Daniel Roseman
On Feb 17, 2:01 pm, "euan.godd...@googlemail.com" wrote: > Why can't you change the dictionary? Can't you just create a copy of > the dict and rename the keys in your copy using _ rather than -  like > so: > > >>> bad = {'var-1':'Apples', 'var-2':'Pears'} > >>> good = dict() > >>> for k,v in bad.

Re: Django Template Hyphenated Keys

2009-02-17 Thread euan.godd...@googlemail.com
Why can't you change the dictionary? Can't you just create a copy of the dict and rename the keys in your copy using _ rather than - like so: >>> bad = {'var-1':'Apples', 'var-2':'Pears'} >>> good = dict() >>> for k,v in bad.items(): >>>good[k.replace('-','_')] = v >>> good {'var_1': 'Apples