-1

I'm new to Python and Django and am developing an web based interview tracker portal.In my portal i have homepage in which there is datatable am not able to display the table values using django where i need to write the code to display the details of the candidate and am using sqlite as my db

  • https://github.com/Chive/django-poll-app – vadimchin Dec 09 '15 at 12:06
  • Why are you "not able" to display them? What happens when you try? – Daniel Roseman Dec 09 '15 at 12:32
  • var dataSet = [ {% for row in candidate_details%} [row.first_name,row.middle_name,row.last_name,row.current_company,row.designation,row.skills,row.experience,row.notice_period, row.location,row.catagory,row.email_id,row.mobile,row.telephone] {%endif%} ]; This is my code – user3500441 Dec 09 '15 at 13:17

2 Answers2

0

I think your description is not quite clear, I guess you want to ask how to visit values of model's attributes in template files. The answer is that you can not visit model's attribute's value in template files directly. You must construct the data in view files first, then pass it to template file. You can visit here to get a clear example.

Community
  • 1
  • 1
yunfeng
  • 28
  • 1
  • 9
0

You posted this code in one of comments:

var dataSet = [ {% for row in candidate_details%} [row.first_name,row.middle_name,row.last_name,row.current_company,row.designatio‌​n,row.skills,row.experience,row.notice_period, row.location,row.catagory,row.email_id,row.mobile,row.telephone] {%endif%} ];

For loop in Django templates should end with {% endfor %}, not {% endif %}. Also there will be syntax error, because you don't separate tables with commas. If you want to do it this way I recommend to write it like that:

var dataSet = [
    {% for row in candidate_details %}
       [row.first_name, ... ]{% if not forloop.last %},{% endif %}
    {% endfor %}
];

But still, I think the best way to send data from server to Javascript would be by using JSON.

rafaljusiak
  • 1,050
  • 1
  • 10
  • 17