Closed AdrianFerJ closed 5 years ago
Hmm this seems like an interesting find! So just to be clear it seems to be the case that when you try to call get_available_cs_event
it would return a django.db.models.fields.related object? So it seems to be the case that it has something to do with the CSEvent.objects.filter
. An interesting find!
Yes, it could be. An easy way to test that would be to replace the query, inside the service itself, with a more generic query that doesn't use filter, the objects.all() kind of query.
The ReservationService.get_available_cs_event() method returns a django.db.models.fields.related object, not a CS event instance, neither a CS instance (as the previous method name suggested, get_available_charging_station() ).
This is not necessarily a bug, but I couldn't figure how to retrieve the related CS from this output. So I moved the query inside the service method, onto the view ChargingStationTopNearListView.get_top_cs_near_poi_available_date() and it did work.
@niroigen , if you know how to retrieve the CS related to the CSEvents, then let's replace this query with a call to the service (I agree it's better practice to have the view and the first query decoupled).