在django中显示用户

时间:2015-05-01 15:53:32

标签: django

我希望在django的html页面中显示来自sqlite3数据库的用户,我编写了代码,但它没有工作

views.py

def showUsers(request):
    conn = sqlite3.connect('testDB')
    c = conn.cursor()
    c.execute("SELECT * FROM person_user where role='simpleuser' ;")
    rows = c.fetchall()
    return render_to_response("all-users.html",{'users':rows,'role':request.session["role"],'username':request.session["username"]})

allusers.html

{% for user in users%}
            <div class="col-lg-4">
                <div class="form_hover " style="background-color: #428BCA;">
                <p style="text-align: center; margin-top: 20px;">
                    <i class="fa fa-user" style="font-size: 147px;"></i>
                </p>
                <div class="header">
                    <div class="blur"></div>
                    <div class="header-text">
                    <div class="panel panel-success" style="height: 247px;">
                        <div class="panel-heading">
                            <h3 style="color: #428BCA;">{{user.username}} Details</h3>
                        </div>
                        <div class="panel-body">
                            <div class="form-group">
                                Name : <b>{{user.username}}</b>
                            </div>
                        <div class="form-group">
                                Role :<b>{{user.role}}</b>
                            </div>
                        </div>
                    </div>
                    </div>
                </div>
                </div>
            </div>
            {% endfor %}

0 个答案:

没有答案