title: How to implement a custom detail serializer on django-rest-auth and serialize it
body: <p>I want to create a profile user when an instance of user is created, i get it but when i run the server it gives me TypeError saying that "NoneType" object is not iterable, i created a <strong>post_save signal</strong> in <strong>UserProfile</strong> model:</p>
  
  <pre><code>@receiver(post_save, sender=User)
  def create_user_profile(sender, instance, created, **kwargs):
      if created:
          UserProfile.objects.create(user=instance)
  
  @receiver(post_save, sender=User)
  def save_user_profile(sender, instance, **kwargs):
      instance.profile.save()
  </code></pre>
  
  <p>my UserProfile model is:</p>
  
  <pre><code>class UserProfile(TimeStampedModel):
  MALE = 'M'
  FEMALE = 'F'
  NOT_SPECIFIED = 'NS'
  
  GENDER_CHOICES = (
      (MALE, _('Male')),
      (FEMALE, _('Female')),
      (NOT_SPECIFIED, _('Not specified'))
  )
  
  VALIDATOR = [validators.RegexValidator(re.compile('^[\w]+$'),
                                         _('Only can has letters'), 'invalid')]
  
  user_profile_id = models.AutoField(primary_key=True)
  user = models.OneToOneField(auth_user, verbose_name=_('user'), blank=False, null=False,
                              on_delete=models.CASCADE, related_name='profile')
  first_name = models.CharField(max_length=125, verbose_name=_('first name'),
                                validators=VALIDATOR, blank=True, null=False)
  last_name = models.CharField(max_length=125, verbose_name=_('last name'),
                               validators=VALIDATOR, blank=True, null=False)
  location = models.ForeignKey(Locations, on_delete=models.DO_NOTHING, verbose_name=_('location'),
                               related_name='location', blank=True, null=True)
  profile_image = models.ImageField(verbose_name=_('profile image'), null=True)
  gender = models.CharField(verbose_name=_('gender'), max_length=2, choices=GENDER_CHOICES, blank=True, null=True,
                            default=NOT_SPECIFIED)
  DOB = models.DateField(verbose_name=_('date of birth'), blank=True, null=True)
  occupation = models.TextField(verbose_name=_('occupation'), blank=True, null=False)
  about = models.TextField(verbose_name=_('about'), blank=True, null=False)
  </code></pre>
  
  <p>I'm using <strong>django-rest-framework</strong>, <strong>django-rest-auth</strong> and <strong>django-allauth</strong>.
  It's my UserProfileSerializer:</p>
  
  <pre><code>class UserProfileSerializer(UserDetailsSerializer):
  # profile_image = ImageSerializer()
  user = UserSerializer(source='profile', many=True)
  
  class Meta:
      model = UserProfile
      fields = '__all__'
      read_only_fields = ('created_at', 'updated_at',)
  
  def update(self, instance, validated_data):
      instance.first_name = validated_data.get('first_name', instance.first_name)
      instance.last_name = validated_data.get('last_name', instance.last_name)
      instance.occupation = validated_data.get('occupation', instance.occupation)
      instance.about = validated_data.get('about', instance.about)
      instance.save()
      return instance
  
  def to_internal_value(self, data):
      user_data = data['user']
      return super().to_internal_value(user_data)
  
  def to_representation(self, instance):
      pass
  </code></pre>
  
  <p>When i access <strong>127.0.0.1:800/rest-auth/user</strong> <em>or</em> <strong>127.0.0.1:800/rest-auth/registration</strong> and register a user appear the following output:</p>
  
  <pre><code>TypeError at /rest-auth/user/
  'NoneType' object is not iterable
  Request Method: GET
  Request URL:    http://127.0.0.1:8000/rest-auth/user/
  Django Version: 3.0.1
  Exception Type: TypeError
  Exception Value:    
  'NoneType' object is not iterable
  Exception Location: C:\PROGRA~1\Python37\venv\lib\site-packages\rest_framework\utils\serializer_helpers.py in __init__, line 18
  Python Executable:  C:\PROGRA~1\Python37\venv\Scripts\python.exe
  Python Version: 3.7.2
  Python Path:    
  ['C:\\Program Files\\Python37\\venv\\Scripts\\asta',
   'C:\\PROGRA~1\\Python37\\venv\\Scripts\\python37.zip',
   'C:\\PROGRA~1\\Python37\\venv\\DLLs',
   'C:\\PROGRA~1\\Python37\\venv\\lib',
   'C:\\PROGRA~1\\Python37\\venv\\Scripts',
   'c:\\program files\\python37\\Lib',
   'c:\\program files\\python37\\DLLs',
   'C:\\PROGRA~1\\Python37\\venv',
   'C:\\PROGRA~1\\Python37\\venv\\lib\\site-packages',
   'C:\\Program Files\\Python37\\venv\\Scripts\\asta\\conf\\backend']
  Server time:    Qui, 6 Fev 2020 15:01:44 +000
  </code></pre>
  
  <p>My <strong>base.py</strong>(settings) is:</p>
  
  <pre><code>    REST_FRAMEWORK = {
      # CHANGE IT, to use oauth2 by django-oauth2-toolkit : already
      'DEFAULT_AUTHENTICATION_CLASSES': (
          'rest_framework.authentication.TokenAuthentication',
          'rest_framework_simplejwt.authentication.JWTAuthentication',
          # 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
          'rest_framework.authentication.SessionAuthentication',
          'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
      ),
      'DEFAULT_PERMISSION_CLASSES': (
          'rest_framework.permissions.IsAuthenticated',
      )
  }
  
  REST_AUTH_REGISTER_SERIALIZERS = {
      'REGISTER_SERIALIZER': 'backend.users.serializers.SignUpSerializer'
  }
  
  REST_AUTH_SERIALIZERS = {
      'USER_DETAILS_SERIALIZER': 'backend.users.serializers.UserProfileSerializer',
      'LOGIN_SERIALIZER': 'backend.users.serializers.CustomLoginSerializer'
  }
  
  REST_USE_JWT = True
  ACCOUNT_LOGOUT_ON_GET = True
  OLD_PASSWORD_FIELD_ENABLED = True
  SOCIALACCOUNT_QUERY_EMAIL = True
  CORS_ORIGIN_ALLOW_ALL = True
  
  JWT_AUTH = {
      'JWT_VERIFY_EXPIRATION': False
  }
  </code></pre>
  
  <p>When i change <code>user = UserSerializer(source='profile', many=True)</code> to <code>user = UserSerializer(source='profile')</code> I got other error :</p>
  
  <pre><code>AttributeError at /rest-auth/user/
  Got AttributeError when attempting to get a value for field `username` on serializer `UserSerializer`.
  The serializer field might be named incorrectly and not match any attribute or key on the `UserProfile` instance.
  Original exception text was: 'UserProfile' object has no attribute 'username'.
  </code></pre>