Hi I'm trying to build a simple django app but I can't get index.html file to recognise the variables created in views.py. Nothing I do seems to work. Does it have to be configured somehow in settings.py perhaps?
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>Hello world {{ name }}</p>
</body>
</html>
views.py:
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def index(request):
context = {'name' : 'Peter'}
return render(request, 'index.html', context)
urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
]
Whatever I try, the browser just doesn't recognise anything in the {{}}. It just leaves it blank. I seem to have tried everything. Please help, I'm tearing my hair out.
Here's the github repo if anyone cares to look at it:
https://github.com/Peterhague/stacqato2
Thanks