Re: Template variables not showing up in web-page

2015-10-24 Thread CTA2052
Thank you for the very speedy reply. I really apprceciate that.  Actually I 
had tried the page/file name in place of the path as well and it still 
would not work. What it turned out to be is, on the back end of a reboot 
(because I took a break to up the memory on my macbook pro,) I rebooted and 
it then worked. Not sure why a reboot fixed it, but it did, just in case 
anyone else has the same problem in the future, that is what worked for me.
Thanks all!
CTA

On Friday, October 23, 2015 at 3:51:57 PM UTC-4, CTA2052 wrote:
>
> Hello All,
>
> This may be the most basic question to ask and believe me it does not come 
> without much research and frustration, but I just can't seem to make it 
> work. So I do apologize ahead of time for even having to post it. I am very 
> new to django (2-months), python(4-months) and in fact programming in 
> general. I have reviewed the online doc sevral times now and various books 
> and tutorials trying to find the answer.
>
> However, I can't seem to get my template variables to render within the 
> web page (crazy I know).
>
> I've tried this many different ways and finally backed-up and 
> stripped-down the code to see what it is I'm missing
>
> *Here is what I have right now in the veiw:*
>
> def response_page(request):
>   
> myv = " fun fun fun "
> context = {'affirmation': myv}
> return render('/response_page/', context )
>
>
> *Here is the template:*
>
>
> 
>
> {% extends "base.html" %}
> {% load static %}
> {% load crispy_forms_tags %}
>
> 
> 
> 
> challenge_engine_response
> 
> 
> {% block content %}
> Testing 1,2,3
>
>
>  I am having so much {{ affirmation }}   
>
> Back to Home Page
>
> 
> {% endblock %}
> 
>
>
> Everything shows up as expected except the variable "affirmation"  which 
> of course should render as "fun fun fun".
>
> I am sure I am missing something silly, but what?
> Thanks in advance for the help.  I have very little hair left at this 
> point (ha).
>
> Thank you all!
>
> Humbly yours,
> CTA2052
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/69ee2f23-f96b-4e4e-90af-cdba160d8dc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template variables not showing up in web-page

2015-10-23 Thread Dheerendra Rathor
signature for request is render(request, template_name, context, **kwargs)

So it should be like render(request, 'response_page.html', context=context)

On Sat, 24 Oct 2015 at 01:21 CTA2052  wrote:

> Hello All,
>
> This may be the most basic question to ask and believe me it does not come
> without much research and frustration, but I just can't seem to make it
> work. So I do apologize ahead of time for even having to post it. I am very
> new to django (2-months), python(4-months) and in fact programming in
> general. I have reviewed the online doc sevral times now and various books
> and tutorials trying to find the answer.
>
> However, I can't seem to get my template variables to render within the
> web page (crazy I know).
>
> I've tried this many different ways and finally backed-up and
> stripped-down the code to see what it is I'm missing
>
> *Here is what I have right now in the veiw:*
>
> def response_page(request):
>
> myv = " fun fun fun "
> context = {'affirmation': myv}
> return render('/response_page/', context )
>
>
> *Here is the template:*
>
>
> 
>
> {% extends "base.html" %}
> {% load static %}
> {% load crispy_forms_tags %}
>
> 
> 
> 
> challenge_engine_response
> 
> 
> {% block content %}
> Testing 1,2,3
>
>
>  I am having so much {{ affirmation }}   
>
> Back to Home Page
>
> 
> {% endblock %}
> 
>
>
> Everything shows up as expected except the variable "affirmation"  which
> of course should render as "fun fun fun".
>
> I am sure I am missing something silly, but what?
> Thanks in advance for the help.  I have very little hair left at this
> point (ha).
>
> Thank you all!
>
> Humbly yours,
> CTA2052
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/5f78b5c5-0652-479f-9ffc-8cd2604967b8%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAByqUgjzhF-36x11T%3DZocVhsRcE71N_nd6grtTRZAMkdq5KRsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Template variables in translation blocks

2013-08-26 Thread Some Developer

On 24/08/13 14:56, Ariel Calzada wrote:

you have to append strings first

http://stackoverflow.com/questions/4386168/how-to-concatenate-strings-in-django-templates

and then call trans



2013/8/24 Some Developer >

I have a title and a header block which normally contain static text
but for some pages I need to display some dynamic information
contained in a template variable.

So I might have the template variable: {{ app.name  }}

and the block code:

{% block title %}
 {% trans "{{ app.name  }} Information" %}
{% endblock %}

Obviously this doesn't work. What is the correct way to solve this
issue? I've done it in the past but I can't for the life of me
remember how.


This was actually significantly easier than described above. The 
following works just fine and is much simpler than having to deal with 
string concatenation in templates.


{% blocktrans with app_name=app.name %}
Edit {{ app_name }}
{% endblocktrans %}

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template variables in translation blocks

2013-08-24 Thread Some Developer

On 24/08/13 14:56, Ariel Calzada wrote:

you have to append strings first

http://stackoverflow.com/questions/4386168/how-to-concatenate-strings-in-django-templates

and then call trans



2013/8/24 Some Developer >

I have a title and a header block which normally contain static text
but for some pages I need to display some dynamic information
contained in a template variable.

So I might have the template variable: {{ app.name  }}

and the block code:

{% block title %}
 {% trans "{{ app.name  }} Information" %}
{% endblock %}

Obviously this doesn't work. What is the correct way to solve this
issue? I've done it in the past but I can't for the life of me
remember how.



Aha. Thank you! I knew there was something I was missing.

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template variables in translation blocks

2013-08-24 Thread Ariel Calzada
you have to append strings first

http://stackoverflow.com/questions/4386168/how-to-concatenate-strings-in-django-templates

and then call trans



2013/8/24 Some Developer 

> I have a title and a header block which normally contain static text but
> for some pages I need to display some dynamic information contained in a
> template variable.
>
> So I might have the template variable: {{ app.name }}
>
> and the block code:
>
> {% block title %}
> {% trans "{{ app.name }} Information" %}
> {% endblock %}
>
> Obviously this doesn't work. What is the correct way to solve this issue?
> I've done it in the past but I can't for the life of me remember how.
>
> --
> 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+unsubscribe@**googlegroups.com
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>



-- 
Ariel Calzada
Homepage: http://www.000paradox000.com
Blog: http://blog.000paradox000.com

"If I had asked people what they wanted, they would have said faster
horses."

 -- Henry Ford

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Template variables and tags confusion... (regarding concatenation)

2009-11-21 Thread chefsmart
Exactly. Thanks.

On Nov 21, 4:45 pm, Tim Chase  wrote:
> > When I do  in a template I get  > id="item_1"> in the rendered html as expected.
>
> > Now I want to do {% cycle '' ' > class="odd" id="item_{{ product.id }}">' %}, but the desired
> > concatenation does not happen.
>
> > How do I achieve what I want?
>
> sounds like you want something like
>
>         id="item_{{ product.id }}">
>
> -tim

--

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




Re: Template variables and tags confusion... (regarding concatenation)

2009-11-21 Thread Tim Chase
> When I do  in a template I get  id="item_1"> in the rendered html as expected.
> 
> Now I want to do {% cycle '' ' class="odd" id="item_{{ product.id }}">' %}, but the desired
> concatenation does not happen.
> 
> How do I achieve what I want?


sounds like you want something like

   

-tim




--

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




Re: Template Variables as Indexes

2009-04-24 Thread Doug B

Might not be the easiest way, but you could use a custom filter:

def formsbyfield(forms,field):
""" Given a list of similar forms, and a field name,
return a list of formfields, one from each form.
"""
return [form.fields.get(field,'') for form in forms]
register.filter('formsbyfield',formsbyfield)

{% for fieldname in forms.0.fields.keys %}

{% for ff in forms|formsbyfield:fieldname %}
{{ff}}
{% endfor %}

{% endfor %}

Something like that should work, though I haven't tested it.


On Apr 24, 11:18 am, NewSpire  wrote:
> I have a list of forms, all of the same type, where I would like to
> list each form side by side with the fields listed vertically.  The
> root of the problem is that I need to use a template variable as an
> index on another template variable.  Something like this.
>
> 
> {% for field in forms.0 %}
> 
>     {{ field.label }}:
>     {% for form in forms %}
>         {{ form.field.{{ forloop.parentloop.counter0 }} }}
>     {% endfor %}
> 
> {% endfor %}
> 
>
> The outer loop if looping over form.0 to create a row for each set of
> fields and the labels.  The inner loop is providing the list of fields
> for each row.  Does anybody see a way to do something like this?
>
> Thanks!
> Andy
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: template variables

2007-10-26 Thread fisher

On Oct 13, 8:09 am, Goon <[EMAIL PROTECTED]> wrote:
> can you use variables in django's templates?
>
> so like {% for x in y %}
>
> and then something like
>
> {% int x =3; x++ %}

Recently I found some handy django snippet which can be usefull for
you.

http://www.djangosnippets.org/snippets/9/

--
Łukasz


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



Re: template variables

2007-10-13 Thread SmileyChris

On Oct 13, 8:35 pm, "Nikola Stjelja" <[EMAIL PROTECTED]> wrote:
> On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
>
> What's the problem. You just send the template 'y':range(1,6). It's very
> simple. I don't think the template system should be changed to do something
> that the programming part of the presentation should do.

Technically, that could be presentation logic. For the common case of
a iterating a set number of times, I wrote 
http://code.djangoproject.com/ticket/5172.


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



Re: template variables

2007-10-13 Thread Jeff Forcier

On Oct 13, 3:41 am, Goon <[EMAIL PROTECTED]> wrote:

> Ok, but let's say I have a template like {{for x in y}}, and I would
> like the x's seperated by commas, but I don't want a comma after the
> last one?  or better yet cut off after the first 100 characters with a
> "..."

The key here is that this sort of logic _can_ be accomplished but it's
done by pushing the logic itself into Python code that's related to
the template - filters and tags. There's a lot of built-in ones
(http://www.djangoproject.com/documentation/templates/) and you can
accomplish both of your examples by applying included template filters
like so:

{% for x in y %}
{{ x }}{% if not forloop.last %},{% endif %}
{% endfor %}

Of course, if you're familiar with Python at all you might recall the
string join method; that's here too and is used for exactly this
purpose. So you can actually do:

{{ y|join:"," }}

As for truncating a string, you could use slice as previously noted:

{{ y|slice:":100" }}...

Basically, you just need to become familiar with the tools available -
there's a lot that can be done with them. If you find a need for
something the builtins don't accomplish by themselves or jointly, you
can easily write your own. Again, the idea being to push non-simple or
non-presentation-oriented logic into Python code that *doesn't* live
in the template - separating the layers, as it were. There's plenty of
documentation on it on the site and on blogs and here on the list as
well, if you ever get stuck :)

Regards,
Jeff


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



Re: template variables

2007-10-13 Thread Nikola Stjelja
On 10/13/07, beck917 <[EMAIL PROTECTED]> wrote:
>
> Maybe use the custom template filters is a nice way~
>
> http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters
>


Yep. The point is: less programming in html, the better. That's the reason
most experienced php developers adopt one templating system, or the other(or
write their own as I did). I think djangos templating system is nice and
clean, and thats the best compliment a ts can receive in my opinion.

2007/10/13, Nikola Stjelja <[EMAIL PROTECTED]>:
> >
> >
> >
> > On 10/13/07, James Bennett < [EMAIL PROTECTED]> wrote:
> > >
> > >
> > > On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> > > > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
> >
> >
> > What's the problem. You just send the template 'y':range(1,6). It's very
> > simple. I don't think the template system should be changed to do something
> > that the programming part of the presentation should do. It makes
> > unreadeble, unpractical html code which just gets in the way of practiacal
> > web development , it's not mantainance friendly.
> >
> > Perhaps the documentation will make you happy:
> > >
> > > http://www.djangoproject.com/documentation/templates/#slice
> > >
> > > --
> > > "Bureaucrat Conrad, you are technically correct -- the best kind of
> > > correct."
> > >
> > > http://www.1km1kt.net/rpg/Marinci.php
> > >
> > >
> > >
> > >
>
> >
>


-- 
Please visit this site and play my RPG!

http://www.1km1kt.net/rpg/Marinci.php

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



Re: template variables

2007-10-13 Thread beck917
Maybe use the custom template filters is a nice way~

http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters


2007/10/13, Nikola Stjelja <[EMAIL PROTECTED]>:
>
>
>
> On 10/13/07, James Bennett <[EMAIL PROTECTED]> wrote:
> >
> >
> > On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> > > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
>
>
> What's the problem. You just send the template 'y':range(1,6). It's very
> simple. I don't think the template system should be changed to do something
> that the programming part of the presentation should do. It makes
> unreadeble, unpractical html code which just gets in the way of practiacal
> web development , it's not mantainance friendly.
>
> Perhaps the documentation will make you happy:
> >
> > http://www.djangoproject.com/documentation/templates/#slice
> >
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of
> > correct."
> >
> > http://www.1km1kt.net/rpg/Marinci.php
> >
> >
> > > >
> >

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



Re: template variables

2007-10-13 Thread Goon



On Oct 13, 3:26 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
>
> > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}
>
> Perhaps the documentation will make you happy:


Ok, but let's say I have a template like {{for x in y}}, and I would
like the x's seperated by commas, but I don't want a comma after the
last one?  or better yet cut off after the first 100 characters with a
"..."



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



Re: template variables

2007-10-13 Thread Nikola Stjelja
On 10/13/07, James Bennett <[EMAIL PROTECTED]> wrote:
>
>
> On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> > fair enough, I'm not happy that I can't get {{for x in y[1:5]}}


What's the problem. You just send the template 'y':range(1,6). It's very
simple. I don't think the template system should be changed to do something
that the programming part of the presentation should do. It makes
unreadeble, unpractical html code which just gets in the way of practiacal
web development , it's not mantainance friendly.

Perhaps the documentation will make you happy:
>
> http://www.djangoproject.com/documentation/templates/#slice
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
>
> >
>


-- 
Please visit this site and play my RPG!

http://www.1km1kt.net/rpg/Marinci.php

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



Re: template variables

2007-10-13 Thread James Bennett

On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> fair enough, I'm not happy that I can't get {{for x in y[1:5]}}

Perhaps the documentation will make you happy:

http://www.djangoproject.com/documentation/templates/#slice

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: template variables

2007-10-13 Thread Goon

fair enough, I'm not happy that I can't get {{for x in y[1:5]}}

dammit!


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



Re: template variables

2007-10-13 Thread James Bennett

On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
> can you use variables in django's templates?

Yes.

> and then something like

> {% int x =3; x++ %}

No.

Django's template language is not Python or any other programming
language. Its sole purpose is presentational logic.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: template variables

2007-10-13 Thread Ramdas S
Simple answer is no. But you can may be try porting mako to to django

On 10/13/07, Goon <[EMAIL PROTECTED]> wrote:
>
>
> can you use variables in django's templates?
>
> so like {% for x in y %}
>
> and then something like
>
> {% int x =3; x++ %}
>
> or something like that, would be mighty helpful
>
>
> >
>

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



Re: Template variables

2006-06-20 Thread Wilson Miner

Hi Patrick,

You might find some helpful responses in this thread:

http://groups.google.com/group/django-users/browse_frm/thread/50ee1c147854769/a79890af3059229d?q=menu=3#a79890af3059229d

On 6/20/06, Patrick <[EMAIL PROTECTED]> wrote:
>
> Hi i'm newbie and i want to publish my Django website.
> I have this "stupid" problem.
> I have a tab bar like this:
>  
> 
>   
> Home^M
>   
>   
> Blog^M
>   
>   
> Tags^M
>   
>   
> Blank^M
>   
> 
>   
>
> There is a possibility to create a variables so i can set the class
> active when i change the section of my website ?
>
> Or i have to create a simple tag ?
>
> Thx
>
> Patrick
>
>
>
> --
> __
> email:[EMAIL PROTECTED]
> http://patrick.pupazzo.org
> __
>
>
>
>
> >
>

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



Re: template variables and looping with attributes

2006-01-22 Thread akaihola

You could define a filter "lookup":

from django.core.template import resolve_variable, Library
register = Library()
def lookup(value, arg):
return resolve_variable(arg, value)
register.filter(lookup)

and use it in your code like this:


{%for r in object_list %}

{%for c in field_list %}
 {{r|lookup:c}}
{%endfor%}

{%endfor%}