title: Create OneToOne field user object in Django serialization
body: <p>I am trying to create the <code>User</code> object using my <code>Staff</code> class. My staff model looks like following,</p>
  <pre class="lang-py prettyprint-override"><code>class Staff(models.Model):
      organization = models.ForeignKey(
          Organization, related_name='staff_organization', on_delete=models.CASCADE, blank=True)
      user = models.OneToOneField(
          User, on_delete=models.CASCADE, blank=True)
      phone = models.CharField(max_length=15, blank=True)
  
      def __str__(self):
          return self.user.username
  </code></pre>
  <p>My serializer class is here,</p>
  <pre class="lang-py prettyprint-override"><code># create staff serializer
  class StaffSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = Staff
          fields = &quot;__all__&quot;
  
      def create(self, validated_data):
          username = validated_data.pop('username')
          email = validated_data.pop('email')
          password = validated_data.pop('password')
          user_instance, created = User.objects.get_or_create(
              username=username, email=email)
  
          if not created:
              user_instance.set_password(password)
  
          staff_instance = Staff.objects.create(
              **validate_data, user=user_instance)
          return staff_instance
  </code></pre>
  <p>Viewset class,</p>
  <pre class="lang-py prettyprint-override"><code>class StaffViewSet(viewsets.ModelViewSet):
      serializer_class = StaffSerializer
      queryset = Staff.objects.all()
      permission_classes = [permissions.IsAuthenticated]
  
  
      def perform_create(self, serializer):
          staff = serializer.save(organization=self.request.user.staff.organization)
          return Response(serializer.data)
  </code></pre>
  <p>I tried the post request as below,</p>
  <pre class="lang-js prettyprint-override"><code>{&quot;username&quot;:&quot;tekson&quot;, &quot;email&quot;:&quot;tekson@gmail.com&quot;, &quot;password&quot;:&quot;admin&quot;}
  </code></pre>
  <p>But it shows the error</p>
  <pre class="lang-js prettyprint-override"><code>{
      &quot;user&quot;: [
          &quot;This field is required.&quot;
      ]
  }
  </code></pre>
  <p>I don't know how to create the user object from the staff. Please help me to figure out this error.</p>