django-push-notifications
django-push-notifications copied to clipboard
How to use this library, noob here
trafficstars
Hey there, I am a beginner so please forgive me if I sound silly. I am trying to make a Rest API using DRF and am using serializers for connecting the models and retrieving the data in ReactJS using the fetch method. I wanted to have the functionality of push notifications, and use the data of the different models in the notifications. I read the documentation and but was not able to figure anything out.
Any suggestions?
how far did you get?
you'll have to trudge through the django docs yourself but with DRF you can make a relatively simple GET/POST/DELETE viewset along these lines in your views.py
from rest_framework import generics
from rest_framework import mixins
from rest_framework import permissions
from rest_framework.serializers import CurrentUserDefault
class APNSDeviceSerializer(serializers.ModelSerializer):
name = serializers.CharField(blank=True, null=True)
active = serializers.BooleanField(default=True)
device_id = serializers.UUIDField(required=True)
registration_id = serializers.CharField(max_length=200)
user = serializers.HiddenField(default=CurrentUserDefault())
class Meta:
model = APNSDevice
class DeviceViewSet(mixins.CreateModelMixin, mixins.ListModelMixin, mixins.DeleteModelMixin):
serializer_class = APNSDeviceSerializer
permission_classes = [permissions.IsAuthenticated]
def get_queryset(self):
return self.request.user.apnsdevice_set.all()