template_source = """
object User "{{ user }}" {
display_name = "{{first_name}} {{last_name}}"
groups = [ "{{ group_name }}" ]
email = "{{ email }}" }
"""
template_source = re.escape(template_source)
template_source = template_source.replace('\\{\\{', '{{')
template_source = template_source.replace('\\}\\}', '{{')
t = Template(template_source)
Django parsing templates to extract variables