Linked Questions

Popular Questions

Hello developers I am stuck to post request automatically by using APScheduler in djangoRestFramework each 2 minutes please help to do it

main problems is pass request in scheduling job.

class LogisticsTruckListView(APIView):
def post(self, request):
    truck_id ='truckListId')
    queryset = LogisticsTruckList.objects.filter(truckListId=truck_id)
    serializer = LogisticsTruckListSerializer(queryset, many=True)
    data =
    # get vehicle no
    vehicle_no = data[0]['vehicle_no']
    if vehicle_no:
        url = ""+vehicle_no
        headers = {
            "Content-type": "application/json",
            "authkey": "UB1CNQLKU32LPCFQJ2NGL7YY1E51HYF6"
        response = requests.get(url, headers=headers, verify=False)
        if response.status_code == 200:
            data = response.json()
            return Response(data, status=status.HTTP_200_OK)
            return Response(status=status.HTTP_400_BAD_REQUEST)
        return Response(status=status.HTTP_400_BAD_REQUEST)

here is my scheduling job code ..

def start():
scheduler = BackgroundScheduler()
viewSets = LogisticsTruckListViewSet()
scheduler.add_job(viewSets.getTrackingDetails(), 'interval', minutes=1,
                  id='tracking_details__001', replace_existing=True)

Help me out soon as possible

I want to schedule a task in django rest framework

Related Questions