我在为我的django项目集成jquerymobile时遇到了困难。尤其是jquerymobile(JQM)的登录功能似乎不是现成的。JQM使用ajax来处理post请求,这是我想要防止的。在这个网站上http://blog.vrplumber.com/index.php?/archives/2511-Miscellaneous-jQuery-Mobile-+-Django-tips.html
我读到有可能通过添加
data-json="false"
但我该怎么补充呢?在模板中还是在视图中?我尝试了不同的变化,但没有效果。在
以下是我的登录视图:
def login(request):
if request.method == 'POST':
username = request.POST['u']
password = request.POST['p']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
auth_login(request, user)
msg.append("Hello %s your login was successful"% username)
return HttpResponseRedirect('/profile/')
else:
msg.append("disabled account")
else:
msg.append("invalid login")
return render_to_response('login.html')
模板如下所示。。。在
^{pr2}$
好吧,我自己想出来了: 只需将此javascript片段添加到模板头部:
相关问题 更多 >
编程相关推荐