0
Hello, I have the following error in an application in Django.
Noreversematch at /Row/Details/2 Reverse for 'get-weatherdata' with keyword Arguments '{'rowId': 1, 'sensorId': 1}' not found. 1 Pattern(s) tried: ['api/weatherData/$'] Request Method: GET Request URL: http://localhost:8000/Row/Details/2 Django Version: 2.2.5 Exception Type: Noreversematch Exception Value: Reverse for get-weatherdata' with keyword Arguments '{'rowId': 1, 'sensorId': 1}' not found. 1 Pattern(s) tried: ['api/weatherData/$']
I need to pass two identifiers as a parameter for the/weatherdata api. I don’t know if I am doing it correctly, but it follows the other codes
py views.
def get_weatherData(request, rowId, sensorId):
weatherData = WeatherData.objects.filter(row_id=rowId, sensor_id=sensorId)
py.
url(r'^api/weatherData/$', get_weatherData, name='get-weatherdata'),
index.html
<script>
{% block jquery %}
var endpoint = '/api/weatherData/'
var defaultData = []
var labels = [];
$.ajax({
method: "GET",
url: endpoint,
success: function(data){
labels = data.date
defaultData = data.value
setChart(labels, defaultData)
},
error: function(error_data){
console.log("error")
console.log(error_data)
}
})
{% endblock %}
</script>
<div class="container" url-endpoint='{% url "get-weatherdata" rowId=1 sensorId=1 %}'>