I programmed using the django rest framework. Since DRF is CRUD automatic, I created a view as shown below.
class PostViewSet(viewsets.ModelViewSet):
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = PostSerializer
queryset = AllfindPost.objects.all()
By the way, I would like to call the following functions when I make a post request.
def send_fcm_notification(ids, title, body):
url = 'https://fcm.googleapis.com/fcm/send'
headers = {
'Authorization': 'key=',
'Content-Type': 'application/json; UTF-8',
}
content = {
'registration_ids': '',
'notification': {
'title': 'title',
'body': 'body'
}
}
requests.post(url, data=json.dumps(content), headers=headers)
What should I do?
Try this. Call your function after post request.