Stop executing template tag

89 views
Skip to first unread message

Nikhil Verma

unread,
Oct 19, 2012, 6:21:39 AM10/19/12
to django...@googlegroups.com
Hello people

I need some suggestion in a problem.

How can i stop django template engine  not executing {{name}}. Meaning I do not want that {{}}, the value should be printed it should somehow pass into the browser as it is.
If i writing {{name}} it should print {{name}} in html file/browser

How can i achieve this ?

--
Regards
Nikhil Verma
+91-958-273-3156

Martin J. Laubach

unread,
Oct 19, 2012, 6:33:00 AM10/19/12
to django...@googlegroups.com
  Just put something between the {{ so the templating engine will not be tempted to interpret it. {<!-- -->{ should do the trick, for example.

Tomas Ehrlich

unread,
Oct 19, 2012, 6:40:38 AM10/19/12
to django...@googlegroups.com
Hi Nikhil,
you can't do that with django template system without additional "raw" tag.

Here's a relevant article:
http://www.holovaty.com/writing/django-two-phased-rendering/

Cheers,
Tom

Dne Fri, 19 Oct 2012 15:51:39 +0530
Nikhil Verma <varma.n...@gmail.com> napsal(a):

Tom Evans

unread,
Oct 19, 2012, 6:43:18 AM10/19/12
to django...@googlegroups.com
On Fri, Oct 19, 2012 at 11:40 AM, Tomas Ehrlich <tomas....@gmail.com> wrote:
> Hi Nikhil,
> you can't do that with django template system without additional "raw" tag.
>
> Here's a relevant article:
> http://www.holovaty.com/writing/django-two-phased-rendering/
>
> Cheers,
> Tom

Oh really?

{% templatetag openvariable %} name {% templatetag closevariable %}

Cheers

Tom

Russell Keith-Magee

unread,
Oct 19, 2012, 6:46:33 AM10/19/12
to django...@googlegroups.com
On Fri, Oct 19, 2012 at 6:21 PM, Nikhil Verma <varma.n...@gmail.com> wrote:
> Hello people
>
> I need some suggestion in a problem.
>
> How can i stop django template engine not executing {{name}}. Meaning I do
> not want that {{}}, the value should be printed it should somehow pass into
> the browser as it is.
> If i writing {{name}} it should print {{name}} in html file/browser

You have two options:

Option 1 - Use the {% templatetag %} templatetag:

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#templatetag

{% templatetag openvariable %} hello {% templatetag closevariable

will render as

{{ hello }}

Option 2 -- if you have a large block of text that you want to render,
you can use the {% verbatim %} template tag

{% verbatim %}
This {{ content }} won't be processed.
{% endverbatim %}

Unfortunately, this option is only available in Django's trunk (so it
will be part of Django 1.5). However, there are plenty of snippets of
code you can use (including copying Django's own implementation) that
you can use in your own project.

Yours,
Russ Magee %-)

Nikhil Verma

unread,
Oct 23, 2012, 1:11:53 PM10/23/12
to django...@googlegroups.com
Thanks to all . But Tome and Russel answers were absolutely correct.Worked like a charm.


{% templatetag openvariable %} hello {% templatetag closevariable





--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages