Tuesday, May 31, 2016

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

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:
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 %}
     
    

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/93bf8fd9-299a-4028-892e-f4638773ab35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment