【发布时间】:2016-05-21 20:45:39
【问题描述】:
我正在尝试显示使用 AJAX 更新的用户列表,同时使用管理页面添加新用户。
Django 1.9,Python 3.5,我正在使用 Windows 机器
我的 index.html
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Email</th>
</tr>
</thead>
<tbody>
{% for User in users %}
<tr>
<td>{{ User.username }}</td>
<td>{{ User.email }}</td>
</tr>
{% endfor %}
</tbody>
</table>
我的意见.py
def index(request):
context = RequestContext(request)
users=User.objects.all()
return render_to_response('index.html',{'users':users},context)
如何实现 AJAX ?请帮助我如何在 Django 中使用 ajax 并完成这个简单的任务。
【问题讨论】:
-
你的问题太笼统了,有很多方法可以实现。此外,您应该修复缩进,因为 Python 对缩进很敏感。
-
你能给我解释一下吗?我是 ajax 和 Django 的新手。我想将用户的名称显示为表格,并在添加新用户后立即更新。就像我们看到通知一样。希望你能帮忙
-
@Selcuk 如果你知道很多方法,你能帮我至少一个吗?评论说你知道不会起作用,而是帮助会起作用。谢谢:)