DEV Community

Vicente G. Reyes
Vicente G. Reyes

Posted on

django.db.utils.IntegrityError: UNIQUE constraint failed: accounts_profile.user_id

I'm having issues with registering a user in my project. I have a custom serializer that inherits from the RegisterView of dj_rest_auth. My code is:

views.py

class ProfileDetail(APIView)
    def get_object(self, pk):
        try:
            return Profile.objects.get(pk=pk)
        except Profile.DoesNotExist:
            raise Http404

    def get(self, request, pk, format=None):
        profile = self.get_object(pk)
        serializer = ProfileSerializer(profile)

Top comments (0)