我開始在Django。Django - 沒有在模板中顯示我的var
我想通過我的模板我的var
將顯示在我的瀏覽器中,但無法正常工作。
這裏是我的views.py
from django.shortcuts import render
from django.http import HttpResponse
from preguntasyrespuestas.models import Pregunta
from django.shortcuts import render_to_response
# Create your views here.
def index(request):
string = 'hi world'
return render_to_response('test/index.html',
{'string': string})
這裏是我的網址:
from django.conf.urls import *
from django.contrib import admin
from django.contrib.auth.views import login
from preguntasyrespuestas.views import index
urlpatterns = [
url(r'^$', index, name='index'),
]
我的html:
<!DOCTYPE html>
<html>
<head>
<title> Preguntas </title>
</head>
<body>
<p>{{ string }}</p>
</body>
</html>
Basicaly我想展示一下我的模板是在string
。但沒有工作..
我的錯誤:
Using the URLconf defined in django_examples.urls, Django tried these URL patterns, in this order:
^$ [name='index']
The current URL, test/index.html, didn't match any of these.
我在做什麼錯?謝謝..