getting error=RegisterAPI' should either include a `serializer_class` 
attribute, or override the `get_serializer_class()` method

models.py:
class Nurse(models.Model):
name = models.CharField(max_length=255, null=False)
email = models.CharField(max_length=255, null=False)
nurseid = models.CharField(max_length=255, null=False)
hospital = models.CharField(max_length=255, null=False)
speciality = models.CharField(max_length=255, null=False)
country = models.CharField(max_length=255, null=False)
city = models.CharField(max_length=255, null=False)
accesscode = models.CharField(max_length=255, null=False)
mobile = models.CharField(max_length=255, null=False)
created_date = models.DateTimeField(auto_now=True)
modified_date = models.DateTimeField(auto_now=True)

VIEWS.PY
class RegisterAPI(viewsets.ModelViewSet):
def create(self, request):
serializer = RegisterSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save()
return Response({"message":"Created successfully",
"success":True,
"address":serializer.data },
status=status.HTTP_200_OK)

SERIALIZERS.PY
class RegisterSerializer(serializers.ModelSerializer):
class Meta:
model = Nurse
fields = '__all__'

-- 
You received this message because you are subscribed to the Google Groups 
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-rest-framework+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/acbb45ff-691d-4b1f-8091-04166bf66653n%40googlegroups.com.

Reply via email to