My code stopped running and this results when I tried to access room Id in the template
The error occurred django.urls.exceptions.NoReverseMatch: Reverse for 'room' with arguments '('',)' not found. 1 pattern(s) tried: ['room/(?P[^/]+)/\Z'][26/Sep/
The template where I tried to access the room id
<a href="{% url 'room' room.id %}">
The url
path('room/<str:pk>/', views.room, name="room"),
The function defined
`def room(request, pk):
room = Room.objects.get(id=pk)
room_messages = room.message_set.all()
participants = room.participants.all()
if request.method == 'POST':
message = Message.objects.create(
user=request.user,
room=room,
body=request.POST.get('body')
)
room.participants.add(request.user)
return redirect('room', pk=room.id)
context = {'room': room, 'room_messages': room_messages,
'participants': participants}
return render(request, 'base/room.html', context)