I have trouble integrating jquery mobile for my django project. Especially the log-in functionality seems not to work out of the box with jquery mobile(JQM). JQM uses ajax for handling post requests, which i want to prevent. On this site http://blog.vrplumber.com/index.php?/archives/2511-Miscellaneous-jQuery-Mobile-+-Django-tips.html
i read that it is possible to prevent JQM from doing that by adding
data-json=”false”
but where do i add that? In the template or in the view? I tried different variations with no effect.
Here is my login view:
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')
the template looks like the following…
{% block content %}
<form action="" method="post">{% csrf_token %}
Login: <input type="text" name="u">
<br/>
Password: <input type="password" name="p">
<input type="submit" value="Login">
</form>
{% if errors %}
<ul>
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
<a href="logout"> Logout </a>
{% endblock %}
okay figured it out by myself:
just add this javascript snippet into your template head: