so do i need to add serializer_class every where i have put serializer?

On Monday, October 26, 2020 at 9:32:56 PM UTC+5:30 beignet...@gmail.com 
wrote:

>
> in RegisterApi add serializer_class=RegisterSerializer , model = Nurse and 
> queryset or get_queryset
> On Monday, 26 October 2020 at 14:24:57 UTC+1 ashutosh...@gmail.com wrote:
>
>> 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/cbc9eade-4b27-4448-849d-5e02c06beb32n%40googlegroups.com.

Reply via email to