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
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.
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
3 matches
Mail list logo