Django Rest Framework extending user model, how to create user
<p>I would like to extend the user model with attributes that are specific to the application, in this case I am simply substituting them with <code>extA</code> and <code>extB</code>. I have made a model to extend the user model and I have created a simple serializer for that model. Now I'm not sure how to create the user with the extra fields.</p>

<p><strong>models.py</strong></p>

<pre><code>class UserDetails(models.Model):

    user = models.OneToOneField(User, on_delete=models.CASCADE)
    extA = models.IntegerField(null=True)
    extB = models.IntegerField(null=True)

@receiver(post_save, sender=User)
def handle_user_save(sender, instance, created, **kwargs):
    if created:
        UserDetails.objects.create(user=instance)
</code></pre>

<p><strong>serializers.py</strong></p>

<pre><code>class UserDetailsSerializer(serializers.ModelSerializer):

    class Meta:
        model = User
        fields = ('id', 'username', 'email', 'extA', 'extB')
</code></pre>

<p><strong>views.py</strong></p>

<pre><code>class UserDetailsView(APIView):

    def get(self, request, id, format=None):
        data = User.objects.get(id)
        serializer_class = UserDetailsSerializer
        return Response(serializer_class.data)
</code></pre>

<p>I have been creating users via the shell. Like this:
<code>user = User.objects.create_user('John', 'john@email.com', 'pass')</code>. This works really well but I'm not sure how to create a <code>UserDetailsView</code> object and save it.</p>