Hi Garg,

Which your expected results in your code!?

Where the points you see errors!?

Plz review again and provide us more details.
Nice.







On Sat, Jan 11, 2020, 18:19 Yash Garg <gargyash...@gmail.com> wrote:

> I have created a User registration rest api app
>
> views.py-
> class UserRegister(APIView):
>
> throttle_classes = [UserRateThrottle]
> def post(self, request, format='json'):
> serializer = UserRegisterSerializer(data=request.data)
> if serializer.is_valid():
> user = serializer.save()
> if user:
> return Response(serializer.data, status=status.HTTP_201_CREATED)
> return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
>
> serializers.py
>
> class UserRegisterSerializer(serializers.ModelSerializer):
>
>     class Meta:
>         model = UserRegister
>         fields = ('first_name', 'last_name', 'email', 'password')
>
>     def save(self):
>       user = UserRegister(first_name = self.validated_data['first_name'],
>                           last_name = self.validated_data['last_name'],
>                           email =  self.validated_data['email'],
>                           password = self.validated_data['password'],
>             )
>       user.save()
>       return user
>
> when i POST the values from postman it gives
> {
>     "first_name": [
>         "This field is required."
>     ],
>     "last_name": [
>         "This field is required."
>     ],
>     "email": [
>         "This field is required."
>     ],
>     "password": [
>         "This field is required."
>     ]
> }
> please suggest how can i resolve this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/129e1948-8472-454f-a89d-c9c596c00766%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/129e1948-8472-454f-a89d-c9c596c00766%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP5HUWpzSY67thJpPvDfDc%3DrO83M52zLv64SX%3D5Oz--xTdia8g%40mail.gmail.com.

Reply via email to