9 lines
160 B
Python
9 lines
160 B
Python
|
from django.template.defaulttags import register
|
||
|
|
||
|
|
||
|
@register.filter
|
||
|
def get(o, key):
|
||
|
if hasattr(o, 'get'):
|
||
|
return o.get(key)
|
||
|
return o[int(key)]
|