I have a problem with django regarding template tags. I have a template tag with a name modal_formwith 4 arguments. This template tag works great with basic variables like:
{% modal_form "clients" contact_form "Contacts" "contact" %}
But this does not work when I try to filter a variable inside my custom template tag, for example:
{% modal_form "parameters" form_dict|key:parameter parameter name_dict|key:parameter %}
This custom filter also works great outside the tag (this filter gets the dict value on a specific key). I have this error:
Caught VariableDoesNotExist on rendering: failed key search [Form_dict | key: parameter]
Maybe I need to write the tag differently to support the filter inside?
This is my code for the tag:
def modal_form(app, object_form, object_name, object_verbose_name):
return { 'app': app, 'object_form': object_form, 'object_name': object_name, 'object_verbose_name': object_verbose_name }
register.inclusion_tag('tags/modal_form.html')(modal_form)
And my code for the filter:
def key(d, key_name):
try:
value = d[key_name]
except KeyError:
#from django.conf import settings
#value = settings.TEMPLATE_STRING_IF_INVALID
value = 0
return value
key = register.filter('key', key)
Do you have any ideas? Do you want more code?
Thanks in advance for your answers.