Object of type ValueError is not JSON serializable
getting this above error. here's my views.py class UserCreateApiView(CreateAPIView): serializer_class = UserCreateSerializer def post(self,request): try: serializer=UserCreateSerializer(data=request.data) if serializer.is_valid(): new_user = User() new_user.highest_degree=serializer.data['highest_degree'] #new_user.state_registered=serializer.data['state_registered'] new_user.country_choices=serializer.data['country_choices'] new_user.save() print(new_user.doc_id) return Response(status=status.HTTP_200_OK) return Response(status=status.HTTP_406_NOT_ACCEPTABLE) except Exception as e: return Response(e) have mentioned all fields in serializers.py On Thursday, April 16, 2020 at 12:57:16 PM UTC+5:30, Antje Kazimiers wrote: > > with a Foreign Key field, one-to-many relationship: > > https://docs.djangoproject.com/en/3.0/topics/db/examples/many_to_one/ > > Antje > On 4/16/20 6:52 AM, shreehari Vaasistha L wrote: > > how can i use model x values as choices for model y ? > > for eg: > class countries(models.Model): > country = models.CharField(max_length=200) > > def __str__(self): > return self.country > > class User(AbstractUser): > """User model.""" > > username = None > full_name = models.CharField(_("Full Name"), max_length=50, default="Full > Name") > country_choices = models.CharField(choices=countries > -- > 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...@googlegroups.com <javascript:>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/683251c6-27ab-4454-90d6-532fdcc749ce%40googlegroups.com > > <https://groups.google.com/d/msgid/django-users/683251c6-27ab-4454-90d6-532fdcc749ce%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/87fad0b6-96d2-43fc-87cf-ffdddc855c5f%40googlegroups.com.