title: How to retrive data from OneToOne Relational Model in DRF using API view
body: <p>I have imported <code>User</code> model and customized it a/c to my need and make OneToOne Relation with <code>UserProfileModel</code> Model. While retrieving data I got this error.
  &quot;The serializer field might be named incorrectly and not match any attribute or key on the <code>AnonymousUser</code> instance.
  Original exception text was: 'AnonymousUser' object has no attribute 'gender'.&quot;</p>
  <p>My Model is :</p>
  <pre><code>class UserProfileModel(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True, related_name='userprofilemodel')
      gender = models.CharField(max_length=20)
      locality = models.CharField(max_length=70)
      city = models.CharField(max_length=70)
      address = models.TextField(max_length=300)
      pin = models.IntegerField()
      state = models.CharField(max_length=70)
      profile_image = models.FileField(upload_to='user_profile_image', blank=True)
  </code></pre>
  <p>My Serializer looks like:</p>
  <p>class UserProfileSerializer(serializers.ModelSerializer):</p>
  <pre><code>class Meta: 
      model= User 
      fields = ['id', 'name' , 'email','mobile',]
  
  class UserProfileModelSerializer(serializers.ModelSerializer):
      user = serializers.StringRelatedField(many=True, read_only=True)
      class Meta: 
          model= UserProfileModel 
          fields = ['user','gender' , 'locality','city','address','pin','state','profile_image', ]
  </code></pre>
  <p>My view looks like:
  class UserProfileDataView(APIView):</p>
  <pre><code>def get(self, request, format=None):
      # user = UserProfileModel.objects.all()
      serializer = UserProfileModelSerializer(request.user)
      return Response(serializer.data, status=status.HTTP_200_OK)
  </code></pre>
  <p>I want to retrieve profile data of the logged user using UserProfileModel Model</p>