Answer the question
In order to leave comments, you need to log in
There is an error when rendering the form in the template, what's wrong?
error when drawing the form in the template:
Reverse for 'sensortoroom' with no arguments not found. 1 pattern(s) tried: ['sensortoroom/(?P[0-9]+)$']
<form action="{% url 'addsensor' %}" method="post">
{% csrf_token %}
{{form.as_p }}
<button type="submit">Save</button>
</form>
urlpatterns = [
...
path('sensortoroom/<int:room_id>', sensortoroom, name='sensortoroom'),
...
]
def sensortoroom(request, room_id):
room = Rooms.objects.filter(id=room_id)
return render(request, 'room/addsensortoroom.html', {'room': room})
Answer the question
In order to leave comments, you need to log in
Well, look ...
You just have the sensortoroom pattern in the urls
in the function 2 arguments, 1 of them is the room ID
Perhaps you really want to see the ID in the jang patterns?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question