0
這是urls.py渲染返回HTML轉換成文本
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.login_page, name='login_page'),
]
我views.py這樣
def login_page(request):
return render(request, 'mileage/login_page.html', {})
這是我的html代碼
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" >
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="{% static 'css/style.css' %}">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js">
</script>
</head>
<body bgcolor="#4599e8">
<div class="title"><span><h1>Test</h1></span></div>
<div class="home_password">
<div class="password"><input type="password" name="password" placeholder="Password"></div>
<div class="button"><button>OK</button></div>
</div>
</body>
</html>
而且啓動服務器,但我的localhost:8080 /只顯示html文本而不是頁面。
使用Chrome開發者控制檯,我檢查了元素。
<html>
<head></head>
<body>
<pre style="word-wrap: break-word; white-space: pre-wrap;">
"
my html code here.
"
</pre>
</body>
</html>
我不知道如何解決它。
你重新啓動了服務器嗎? – Sayse
@Sayse肯定.... – LeeJaeng