Re: passing a list of list to a template

2015-02-14 Thread Adailton (Dhelbegor)
#views def tests(request): acept = get_object_or_404(Modeltest, released=True) context = {'keys': acept} # [1] return render(request, 'temp_test.html', context) #template {% for key in keys %} # [1] {{key.title}} {{key.name}} {{key.number}} {{key.etc}} {% endfor %}

Re: passing a list of list to a template

2015-02-13 Thread Vijay Khemlani
I think you can make comparisons, but try to limit the amount of logic that you implement in your templates. On Fri, Feb 13, 2015 at 6:14 PM, dk wrote: > I am assuming in django doing i.1 or i.2 will be the same as i[1], > i[2] right? > > can I do if statements too? like if i.2 == to somest

Re: passing a list of list to a template

2015-02-13 Thread dk
I am assuming in django doing i.1 or i.2 will be the same as i[1], i[2] right? can I do if statements too? like if i.2 == to somestuff? do something? or all that need to be set in the view function? thanks On Thursday, February 12, 2015 at 12:15:50 PM UTC-6, Vijay Khemlani wrote: > If

Re: passing a list of list to a template

2015-02-12 Thread ADEWALE ADISA
What of: {% for i in lista %} {% for j in i %} {{ j }} {% endfor %} {% endfor %} On Feb 12, 2015 6:55 PM, "dk" wrote: > i do have a list of list like this > [ [apple, banana, red] , [orange, grape, blue] , [watermelon, >

Re: passing a list of list to a template

2015-02-12 Thread monoBOT
{% for x, y in points %} There is a point at {{ x }},{{ y }}{% endfor %} extracted from: https://docs.djangoproject.com/en/1.7/ref/templates/builtins/ 2015-02-12 18:55 GMT+01:00 dk : > i do have a list of list like this > [ [apple, banana, red] , [orange, grape, blue] , [watermelon,

Re: passing a list of list to a template

2015-02-12 Thread Vijay Khemlani
If you have a fixed number of items in each of the sublists you can do {{ i.0 }} # First element {{ i.1 }} # Second element or you can iterate over it {% for sub_element in i %} {{ sub_element }} {% endfor %} On Thu, Feb 12, 2015 at 2:55 PM, dk wrote: > i do have a list of list like

passing a list of list to a template

2015-02-12 Thread dk
i do have a list of list like this [ [apple, banana, red] , [orange, grape, blue] , [watermelon, tangerine, purple] ] then i am passing it to the template like return render(request, "show_table.html", {"lista": lista}) inside my template html i have {% for i in lista %}