why blank page when load a list or dictionary into web to display a list

31 views
Skip to first unread message

meInvent bbird

unread,
May 27, 2016, 5:57:32 AM5/27/16
to Django users

Akhil Lawrence

unread,
May 28, 2016, 10:22:01 AM5/28/16
to Django users
Dude,

You need to make the following changes.

1. you need to pass a dictionary as the context in your views

     return render(request, 'approval.html', {'posts': posts})

2. the prefer the posts to be list of dict

    change 

    posts = {}
    ...............................
    LL = [(1,eachbracket)]
    posts.update(LL)

    to
    
    posts = []
    ..........................................
    posts.append(eachbracket)

 3. you templates syntax is wrong correct it, use {{ }}

    {% block content %}
    <table>
    {% for post in posts %}
      <tr>
        <td>
          {{ post.project }}
        </td>
        <td>
          {{ post.company }}
        </td>
        <td>
          {{ post.name }}
        </td>
        <td>
          {{ post.businessType }}
        </td>
        <td>
          {{ post.userType }}
        </td>
      </tr>
    {% endfor %}
    </table>
{% endblock %}
     
    

meInvent bbird

unread,
May 31, 2016, 9:45:08 PM5/31/16
to Django users
really really thanks

after tried, it works.

meInvent bbird

unread,
May 31, 2016, 10:46:36 PM5/31/16
to Django users
if checked a few check box and save, 

how to add check box field and get the value of checkboxes?


https://drive.google.com/file/d/0Bxs_ao6uuBDUeW9BQzA1RTlHZEE/view?usp=sharing

the number of rows in http://x.x.x.x/reg/approval.html
depend on data in csv, 



On Saturday, May 28, 2016 at 10:22:01 PM UTC+8, Akhil Lawrence wrote:
Reply all
Reply to author
Forward
0 new messages