variable in django template

40 views
Skip to first unread message

Harjot Mann

unread,
Oct 23, 2013, 5:00:46 AM10/23/13
to django...@googlegroups.com
I want to initialize a varibale in django template from zero, which I
want to comapre with the some job_no whihc is coming from database. I
am not getting hoe to decalre a variable. Please help me .
--
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

Leonardo Giordani

unread,
Oct 23, 2013, 7:03:48 AM10/23/13
to django...@googlegroups.com
Hi,

everything you need in a template can be prepared in a view, so if you need a specific value just pass a context key with that very value.
Otherwise, if you need a list of integers, just pass a range(N) list.
There is a plenty of builtin filters and tags you can then use to manage it.

If you can better clarify what you want to accomplish, I can perhaps be more specific.

Regards,
Leo

Leonardo Giordani
Author of The Digital Cat
My profile on About.me - My GitHub page - My Coderwall profile


2013/10/23 Harjot Mann <harjotm...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAB0GQhBfRf3cK-YZ1R90rNaKWgUunVZ_R_nxynSD8LuXQOGoWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Nicolas Pantel

unread,
Oct 23, 2013, 7:06:32 AM10/23/13
to django...@googlegroups.com

Take a look at the "{@ with @}" template tag in the documentation. Use {@ with myVariable=someValue @} ... {@ endwith @}.

NicoP

Leonardo Giordani

unread,
Oct 23, 2013, 2:14:22 PM10/23/13
to django...@googlegroups.com
Indeed this is a good solution. Just a typo correction, use "%" instead of "@".

Leo

Leonardo Giordani
Author of The Digital Cat
My profile on About.me - My GitHub page - My Coderwall profile


2013/10/23 Nicolas Pantel <nicolas...@gmail.com>
Reply all
Reply to author
Forward
0 new messages