title: Get following error when creating user in Django: type object 'User' has no attribute 'objects'
body: <p>I have written a view to register a new user for my app but when I try running it, I get the error:</p>
  
  <pre><code>type object 'User' has no attribute 'objects'
  </code></pre>
  
  <p>My code looks as follows:</p>
  
  <pre><code>from django.contrib.auth import authenticate, login, logout
  from django.contrib.auth.models import User
  from django.contrib.auth.decorators import login_required
  from django.core import serializers
  
  from rest_framework.views import APIView
  from rest_framework.response import Response
  
  from users.serializers import *
  
  class Register(APIView):
  
      def post(self, request):
          serialized = UserSerializer(data=request.DATA)
          if serialized.is_valid():
              user = User.objects.create_user(serialized.init_data['email'], serialized.init_data['username'], serialized.init_data['password'])
              return Response(serialized.data, status=status.HTTP_201_CREATED)
          else:
              return Response(serialized._errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p><strong>Edit:</strong>
  My user.serializers module looks as follows:</p>
  
  <pre><code>from django.forms import widgets
  from rest_framework import serializers
  from django.contrib.auth import get_user_model
  
  class UserSerializer(serializers.ModelSerializer):
      class Meta:
          model = get_user_model()
          fields = ('date_joined','email','first_name','id','last_login','last_name','username')
  </code></pre>