File tree Expand file tree Collapse file tree 3 files changed +7
-5
lines changed
templates/forecastmanager Expand file tree Collapse file tree 3 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ def to_representation(self, instance):
4848 'max_temp' : representation ['max_temp' ],
4949 'min_temp' : representation ['min_temp' ],
5050 'condition' :representation ['condition_display' ],
51- 'condition_icon' : f'/ static/forecastmanager/img/{ representation ["condition" ]} .png' ,
51+ 'condition_icon' : f'static/forecastmanager/img/{ representation ["condition" ]} .png' ,
5252 },
5353 "geometry" : {
5454 "coordinates" : representation ['city_detail' ]['coordinates' ],
Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ <h2 class="w-panel__heading">Add forecast</h2>
189189 var city_ls = JSON . parse ( '{{city_ls|escapejs}}' )
190190
191191 const container = document . querySelector ( '#createTable' ) ;
192+ const BASE_URL = '{{request.get_full_path}}'
192193
193194
194195 const hot = new Handsontable ( container , {
@@ -327,7 +328,7 @@ <h2 class="w-panel__heading">Add forecast</h2>
327328
328329 // Send the JSON data to a Django view via AJAX
329330 $ . ajax ( {
330- url : ' /api/forecasts/' ,
331+ url : ` ${ BASE_URL } /api/forecasts/` ,
331332 type : 'POST' ,
332333 headers : {
333334 'X-CSRFToken' : '{{ csrf_token }}' , // Replace with the actual CSRF token value
Original file line number Diff line number Diff line change @@ -61,10 +61,11 @@ <h2 class="w-panel__heading">Latest Available Forecast</h2>
6161
6262
6363 < script type ="text/javascript ">
64-
64+
6565
6666 document . addEventListener ( "DOMContentLoaded" , function ( ) {
6767
68+ const BASE_URL = '{{request.get_full_path}}'
6869 // initialize map
6970 var forecastMap = new maplibregl . Map ( {
7071 container :'forecast_map' ,
@@ -152,7 +153,7 @@ <h2 class="w-panel__heading">Latest Available Forecast</h2>
152153 function setForecastData ( forecast_date ) {
153154
154155 // Make an HTTP GET request to the API endpoint
155- fetch ( `/ api/forecasts?forecast_date=${ forecast_date } ` )
156+ fetch ( `${ BASE_URL } api/forecasts?forecast_date=${ forecast_date } ` )
156157 . then ( response => response . json ( ) ) // Parse the response as JSON
157158 . then ( data => {
158159 // Process the retrieved data
@@ -167,7 +168,7 @@ <h2 class="w-panel__heading">Latest Available Forecast</h2>
167168 }
168169
169170 }
170- img . src = `${ icon . properties . condition_icon } `
171+ img . src = `${ BASE_URL } ${ icon . properties . condition_icon } `
171172 return img . src
172173
173174 } )
You can’t perform that action at this time.
0 commit comments