TEMPLATE_DIRS = ( os.path.join(os.path.dirname(__file__), 'templates'), )三、在index.py中改相應代碼:
from django.template.loader import get_template from django.template import Context from django.http import HttpResponse def current_datetime(request): t = get_template('index.html') html = t.render(Context({'msg': 'hello python!'})) return HttpResponse(html)
或者:
html
from django.shortcuts import render_to_response def wel(request): return render_to_response('index.html', {'msg': 'hello python!'})