title: Django IntegrityError: (1048, "Column 'user_id' cannot be null")
body: <p>This is my models.py</p>
  
  <pre><code>class Cfituser(models.Model):
  user = models.OneToOneField(User)
  socialid = models.IntegerField(null=True)
  accesstoken = models.CharField(max_length=255L, null = True)
  class Meta:
      db_table = 'CfitUser'
  def __str__(self):  
        return "%s's profile" % self.user  
  
  @receiver(post_save, sender=User)
  def create_cfituser(sender, instance, created, **kwargs):  
      if created:  
          Cfituser.objects.get_or_create(user=instance) 
  </code></pre>
  
  <p>This is my views.py</p>
  
  <pre><code>@api_view(['GET', 'POST'])
  def users_create(request, format = None):
  """
  List all users, or create a new user.
  """
  if request.method == 'GET':
      cfituser = Cfituser.objects.all()
      serializer = CfituserSerializer(cfituser, many=True)
      return Response(serializer.data)
  
  elif request.method == 'POST':
      serializer = CfituserSerializer(data=request.DATA)
      if serializer.is_valid():
              print serializer.data
              user = User.objects.create_user(username = serializer.data['socialid'])
              cfituser = Cfituser.objects.get(user = user)
              cfituser.accesstoken = serializer.data['accesstoken']
              cfituser.socialid = serializer.data['socialid']
              cfituser.save()
              serializer.save()
              return Response(serializer.data, status=status.HTTP_201_CREATED)
      else:
          return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  
  <p>Whenever there is a HTTP Post request, my database tables are filled in as expected but this error keeps popping up. I've tried almost every solution available on SO but I'm stuck with this. </p>
  
  <p>I have tried <code>user = models.OneToOneField(User, null = True)</code> but this leads to two entries in my database table, one with <code>user_id = NULL</code> and one with <code>user_id = actualvalue</code>. </p>
  
  <p>Any suggestions on how to fix this?</p>