장고에서 시작합니다.장고 - 템플릿에 내 var가 표시되지 않습니다.
내 템플릿에 내 var
을 내 브라우저에 표시하려고하지만 전달하지 않으려 고합니다.
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
에 무엇이 표시 할
여기 내 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})
여기 내 URL을합니다. 하지만 .. 작동하지
내 오류 : 내가 잘못 뭐하는 거지
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.
? 고맙습니다 ..