I haven't used Django
for a while, so I forgot many things of Django
. When I click url link on this site的方式,它移动到另一个页面,但页面不能正常工作。但是,如果我重新加载页面或重新键入相同的URL,则页面可以正常工作。
我这样写了,
<a href="{% url 'slideup_like_magic' %}">slideUp header</a>
或
<a href="/carousel/">carousel</a>
我看过几页,但我不知道该怎么做。你能帮帮我吗?
的index.html
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en-EN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- for IE -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<title>Welcome to my Samples!</title>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css">
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<style type="text/css"></style>
</head>
<body>
<div>
<span>Welcome to my samples!!</span>
<dl>
<dt>Bootstrap</dt>
<dd><a href="{% url 'affix' %}">affix</a></dd>
<dd><a href="/carousel/">carousel</a></dd>
<dt>BxSlider</dt>
<dd><a href="/bxslider/">responsive</a></dd>
<dt>Magic</dt>
<dd><a href="{% url 'slideup_like_magic' %}">slideUp header</a></dd>
</dl>
</div>
<!-- JavaScript -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js" type="text/javascript" ></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js type="text/javascript" ></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>
<script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript"></script>
</body>
</html>
url.py
from django.conf.urls import include, url
from django.contrib import admin
admin.autodiscover()
import hello.views
# Examples:
# url(r'^$', 'gettingstarted.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
urlpatterns = [
url(r'^$', hello.views.index, name='index'),
url(r'^bxslider/$', hello.views.bxslider, name='bxslider'),
url(r'^affix/$', hello.views.affix, name='affix'),
url(r'^carousel/$', hello.views.carousel, name='carousel'),
url(r'^slideup_like_magic/$', hello.views.slideup_like_magic, name='slideup_like_magic'),
url(r'^db', hello.views.db, name='db'),
url(r'^admin/', include(admin.site.urls)),
]
Django-1.9.2
//////补充//////
这是我从http://bananaman.herokuapp.com/
移动页面时看到的内容。
这就是我应该看到的,例如,http://bananaman.herokuapp.com/slideup_like_magic
。
答案 0 :(得分:2)
我还没有费心去处理所有正在发生的事情,但看起来你遇到的问题是由于jQuery Mobile的链接劫持。从一个页面到下一个页面,您的data-*
属性看起来不正确。
我认为你应该从拉出jQuery Mobile开始,确保一切正常。然后添加jQuery Mobile,确保您使用正确的data-role
属性设置页面。