点击no后。
输入图片描述
检查这里
输入图片描述
code HTML here
{% extends "main.html" %}
{% block content %}
<h1>{{room.name}}</h1>
{% endblock content %}
code python这里我不知道这里是否有问题
from django.shortcuts import render
rooms = [
{'id': 1, 'name': 'Lets learn python!'},
{'id': 2, 'name': 'Design with me!'},
{'id': 3, 'name': 'Fronted develpoers!'},
]
def home(request):
context = {'rooms': rooms}
return render(request, 'base/home.html', context)
def room(request, pk):
room = None
for i in rooms:
if i['id'] == int(pk):
room = i
context = {'romm': room}
return render(request, 'base/room.html', context)
我想你把room
上下文拼错了。
而不是:
<h1>{{room.name}}</h1>
试试这个:
<h1>{{romm.name}}</h1>