Re: [novice question] Render a list of objects

2019-06-24 Thread Sudeep Gopal
Update  This worked for me..Thanks a lot for your help:- 

 FIELD1 FIELD2 FIELD3 FIELD4 
FIELD5 FIELD6 FIELD7 FIELD8 * {% for r in 
ret_list %} *   {{r.field1}}   {{r.field2}}   
{{r.field3}}   {{r.field4}}  {{r.field5}}   
{{r.field6}}   {{r.field7}}   {{r.field8 }}   * 
{% endfor %} *



On Sunday, June 23, 2019 at 8:15:58 PM UTC-4, Sudeep Gopal wrote:
>
> Thank you so much Joe...
>
> I was actually able to go forward. 
>
> With the below code  :-
>
> 
>   {% for r in list1 %}
> {% cycle '' '' '' '' '' '' '' ''%}
>   {{r}}
> {% cycle '' '' '' '' '' '' '' '' %}
>   {% endfor %}
>
>
>
> The {{r}} in the above code , gives only the reference or the pointer 
> value. For eg, template cannot recognize it is field1 which I want to 
> display or something,,,
> How do we get the value of that reference ?
>
> My result look like this :-
>
> field1 field2 field3 field4 field5 field6 field7 
>  
>  object at 0x0581B550>  object at 0x0581B278>  object at 0x05413908>  object at 0x053C27F0>  object at 0x053C20B8>  object at 0x053C2278> 
>  
>  object at 0x05413668>  object at 0x05413358>  object at 0x05413DA0>  object at 0x054DDF98>  object at 0x053C2978>  object at 0x055943C8> 
>
> I want it to look at the content 
>
> CARRIER1 230 128 QPSK 1000 125 155 
> CARRIER2 230 256 QAM 1000 125 155 
>
>
>
> On Saturday, June 22, 2019 at 9:03:19 AM UTC-4, Joe Reitman wrote:
>>
>> The example code you provided will create a  on the first iteration 
>> of the loop and  tag every 4th iteration of the loop. This cycle will 
>> continue resulting in a table with 4 columns of data. Example:
>>
>> results = [ 1, 2, 3, 4, 5, 6, 7, 8 ]
>>
>>
>> 
>>   
>> 1
>> 2
>> 3
>> 4
>>   
>>   
>> 5
>> 6
>> 7
>> 8
>>   
>>
>>
>>
>> If you have 2 lists, render them from your view like return render(
>> request, 'polls/detail.html', {'list1': list1, 'list2': list2})
>> In your template create an 8 column table:
>>
>> 
>>   {% for r in list1 %}
>> {% cycle '' '' '' '' '' '' '' ''%}
>>   {{r}}
>> {% cycle '' '' '' '' '' '' '' '' %}
>>   {% endfor %}
>>
>> {% for r in list2 %}
>> {% cycle '' '' '' '' '' '' '' ''%}
>>   {{r}}
>> {% cycle '' '' '' '' '' '' '' '' %}
>>   {% endfor %}
>>
>> 
>>
>>
>> Hope this helps
>>
>> On Friday, June 21, 2019 at 5:58:21 PM UTC-5, Sudeep Gopal wrote:
>>>
>>> Hello, 
>>>
>>> I am new to django. 
>>>
>>> I am using django forms in my project and I am not using django models. 
>>>
>>> From the user,  my django form asks for 4 inputs :- signal_to_noise_1 , 
>>> signal_to_noise_2, bandwidth1 and bandwidth2. 
>>>
>>> Based on these values I use my  look up table and I create a results 
>>> which are 2 lists of records.
>>>  Each list has approximately 40 to 50 records. Each record has 8 fields. 
>>> (field1,...field8) ...
>>>
>>> *Each list *looks like this (if my description is not clear) field1 is 
>>> unique. 
>>>
>>> field1  field2  field3 
>>>
>>>
>>>
>>> field8
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Both the lists (with each list having about 50 records) are in my django 
>>> view. 
>>>
>>> From what I read online, I can use the render() method which has a 
>>> *dictionary 
>>> *called context. (
>>> https://docs.djangoproject.com/en/2.2/ref/templates/api/#rendering-a-context
>>>  
>>> 
>>> )
>>>
>>> I am not sure how to convert these list of record objects to this 
>>> dictionary format which has {"name":value} pair. 
>>>
>>> Even the django tables requires it in the dictionary format.
>>>
>>> The nearest thing which I found was 
>>> https://stackoverflow.com/questions/9388064/django-template-turn-array-into-html-table
>>>  
>>>
>>> But I did not understand what exactly the below syntax does and how I 
>>> can customize it to my usecase any input would be greatly appreciated 
>>> ...
>>>
>>> 
>>>   {% for r in results %}
>>> {% cycle '' '' '' '' %}
>>>   {{r.content}}
>>> {% cycle '' '' '' '' %}
>>>   {% endfor %}
>>>
>>>
>>>
>>>
>>>
>>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8331c29f-97ce-4ec6-9aa9-67c36c0997ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [novice question] Render a list of objects

2019-06-23 Thread Sudeep Gopal
Thank you so much Joe...

I was actually able to go forward. 

With the below code  :-


  {% for r in list1 %}
{% cycle '' '' '' '' '' '' '' ''%}
  {{r}}
{% cycle '' '' '' '' '' '' '' '' %}
  {% endfor %}



The {{r}} in the above code , gives only the reference or the pointer 
value. For eg, template cannot recognize it is field1 which I want to 
display or something,,,
How do we get the value of that reference ?

My result look like this :-

field1 field2 field3 field4 field5 field6 field7 
 
  
 
  

I want it to look at the content 

CARRIER1 230 128 QPSK 1000 125 155 
CARRIER2 230 256 QAM 1000 125 155 



On Saturday, June 22, 2019 at 9:03:19 AM UTC-4, Joe Reitman wrote:
>
> The example code you provided will create a  on the first iteration of 
> the loop and  tag every 4th iteration of the loop. This cycle will 
> continue resulting in a table with 4 columns of data. Example:
>
> results = [ 1, 2, 3, 4, 5, 6, 7, 8 ]
>
>
> 
>   
> 1
> 2
> 3
> 4
>   
>   
> 5
> 6
> 7
> 8
>   
>
>
>
> If you have 2 lists, render them from your view like return render(request
> , 'polls/detail.html', {'list1': list1, 'list2': list2})
> In your template create an 8 column table:
>
> 
>   {% for r in list1 %}
> {% cycle '' '' '' '' '' '' '' ''%}
>   {{r}}
> {% cycle '' '' '' '' '' '' '' '' %}
>   {% endfor %}
>
> {% for r in list2 %}
> {% cycle '' '' '' '' '' '' '' ''%}
>   {{r}}
> {% cycle '' '' '' '' '' '' '' '' %}
>   {% endfor %}
>
> 
>
>
> Hope this helps
>
> On Friday, June 21, 2019 at 5:58:21 PM UTC-5, Sudeep Gopal wrote:
>>
>> Hello, 
>>
>> I am new to django. 
>>
>> I am using django forms in my project and I am not using django models. 
>>
>> From the user,  my django form asks for 4 inputs :- signal_to_noise_1 , 
>> signal_to_noise_2, bandwidth1 and bandwidth2. 
>>
>> Based on these values I use my  look up table and I create a results 
>> which are 2 lists of records.
>>  Each list has approximately 40 to 50 records. Each record has 8 fields. 
>> (field1,...field8) ...
>>
>> *Each list *looks like this (if my description is not clear) field1 is 
>> unique. 
>>
>> field1  field2  field3 
>>
>>
>>
>> field8
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Both the lists (with each list having about 50 records) are in my django 
>> view. 
>>
>> From what I read online, I can use the render() method which has a 
>> *dictionary 
>> *called context. (
>> https://docs.djangoproject.com/en/2.2/ref/templates/api/#rendering-a-context 
>> 
>> )
>>
>> I am not sure how to convert these list of record objects to this 
>> dictionary format which has {"name":value} pair. 
>>
>> Even the django tables requires it in the dictionary format.
>>
>> The nearest thing which I found was 
>> https://stackoverflow.com/questions/9388064/django-template-turn-array-into-html-table
>>  
>>
>> But I did not understand what exactly the below syntax does and how I can 
>> customize it to my usecase any input would be greatly appreciated ...
>>
>> 
>>   {% for r in results %}
>> {% cycle '' '' '' '' %}
>>   {{r.content}}
>> {% cycle '' '' '' '' %}
>>   {% endfor %}
>>
>>
>>
>>
>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4f66e9a2-7a4b-467b-95f8-b13bc904b791%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [novice question] Render a list of objects

2019-06-22 Thread Joe Reitman
The example code you provided will create a  on the first iteration of 
the loop and  tag every 4th iteration of the loop. This cycle will 
continue resulting in a table with 4 columns of data. Example:

results = [ 1, 2, 3, 4, 5, 6, 7, 8 ]



  
1
2
3
4
  
  
5
6
7
8
  



If you have 2 lists, render them from your view like return render(request, 
'polls/detail.html', {'list1': list1, 'list2': list2})
In your template create an 8 column table:


  {% for r in list1 %}
{% cycle '' '' '' '' '' '' '' ''%}
  {{r}}
{% cycle '' '' '' '' '' '' '' '' %}
  {% endfor %}

{% for r in list2 %}
{% cycle '' '' '' '' '' '' '' ''%}
  {{r}}
{% cycle '' '' '' '' '' '' '' '' %}
  {% endfor %}




Hope this helps

On Friday, June 21, 2019 at 5:58:21 PM UTC-5, Sudeep Gopal wrote:
>
> Hello, 
>
> I am new to django. 
>
> I am using django forms in my project and I am not using django models. 
>
> From the user,  my django form asks for 4 inputs :- signal_to_noise_1 , 
> signal_to_noise_2, bandwidth1 and bandwidth2. 
>
> Based on these values I use my  look up table and I create a results which 
> are 2 lists of records.
>  Each list has approximately 40 to 50 records. Each record has 8 fields. 
> (field1,...field8) ...
>
> *Each list *looks like this (if my description is not clear) field1 is 
> unique. 
>
> field1  field2  field3 
>
>
>
> field8
>
>
>
>
>
>
>
>
>
>
>
> Both the lists (with each list having about 50 records) are in my django 
> view. 
>
> From what I read online, I can use the render() method which has a 
> *dictionary 
> *called context. (
> https://docs.djangoproject.com/en/2.2/ref/templates/api/#rendering-a-context 
> 
> )
>
> I am not sure how to convert these list of record objects to this 
> dictionary format which has {"name":value} pair. 
>
> Even the django tables requires it in the dictionary format.
>
> The nearest thing which I found was 
> https://stackoverflow.com/questions/9388064/django-template-turn-array-into-html-table
>  
>
> But I did not understand what exactly the below syntax does and how I can 
> customize it to my usecase any input would be greatly appreciated ...
>
> 
>   {% for r in results %}
> {% cycle '' '' '' '' %}
>   {{r.content}}
> {% cycle '' '' '' '' %}
>   {% endfor %}
>
>
>
>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/600c0fd5-8682-493e-ba8e-4c2cdba31776%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.