title: PYTHON/DJANGO: "SUser.user" must be a "User" instance
body: <p>I have a problem with adding new custom user to the database. I know thare's some threads about it on the internet but I couldn't find solution for my problem. After hitting "Submit" button in registration page which template is here:</p>
  
  <pre><code>{% extends 'strona/Main.html' %}
  {% block body %}
  &lt; form action="" method="post" enctype="multipart/form-data" &gt;
      {% csrf_token %}
      {% for field in form %}
          {{ field.label_tag }}
          &lt; /br &gt;
          {{ field }}
          &lt; /br &gt;
          &lt; /br &gt;
      {% endfor %}
      &lt; button type="submit" class="btn btn-success"&gt;Submit&lt;/button &gt;
  &lt; /form &gt;
  {% endblock %}
  </code></pre>
  
  <p>it keeps saying that: <strong>"Cannot assign "&lt; SimpleLazyObject: &lt; django.contrib.auth.models.AnonymousUser object at 0x038B5A70 >>": "SUser.user" must be a "User" instance."</strong></p>
  
  <p><strong><em>Source Codes:</em></strong></p>
  
  <p><strong>VIEWS.PY</strong></p>
  
  <pre><code>class RegPanelView(View):
  panel = RegPanel
  template_name = 'strona/RegistrationTemp.html'
  registration = None
  
  def get(self, request):
      form = self.panel(None)
      return render(request, self.template_name, {'form': form})
  
  def post(self, request):
      # form = self.panel(data=request.POST)
      form = self.panel(request.POST)
  
      if form.is_valid():
          # user = form.save(commit=False)
  
          # username = form.cleaned_data['username']
          password1 = form.cleaned_data['password1']
          password2 = form.cleaned_data['password2']
  
          if password1 == password2:
  
              newuser = form.save(commit=False)
              newuser.user = request.user
              newuser.save()
  
              return redirect('strona:index')
      return render(request, self.template_name, {'form': form})
  </code></pre>
  
  <p><strong>MODELS.PY</strong></p>
  
  <pre><code>class SUser(models.Model):
  # User = user_model()
  user = models.OneToOneField(User, on_delete=models.CASCADE)
  username = models.CharField(max_length=200)
  # last_login = models.DateTimeField(blank=True)
  # is_active = models.BooleanField(default=True)
  is_staff = models.BooleanField(default=False)
  first_name = models.CharField(max_length=200)
  last_name = models.CharField(max_length=200)
  relations = models.ManyToManyField('self')
  # is_anonymous = False
  # is_authenticated = True
  
  USERNAME_FIELD = 'username'
  REQUIRED_FIELDS = ('', )
  </code></pre>
  
  <p><strong>FORMS.PY</strong></p>
  
  <pre><code>class RegPanel(UserCreationForm):
  
  # password = forms.CharField(max_length=16, widget=forms.PasswordInput)
  # first_name = forms.CharField(max_length=100, required=False)
  # last_name = forms.CharField(max_length=100, required=False)
  # is_staff = forms.BooleanField(required=False)
  
  # birthday = forms.DateField(required=False)
  
  class Meta:
      model = SUser
      fields = ['username', 'is_staff', 'first_name', 'last_name']
  
  
  
  
  
  def save(self, commit=True):
      user = super(UserCreationForm, self).save(commit=False)
      # user.set_password(self.cleaned_data["passwosrd1"])
      if commit:
  
  
  
          user.set_password(self.cleaned_data["password1"])
          user.save()
          # if commit:
          # user.save()
  
      return user
  </code></pre>
  
  <p><strong>SETTINGS.PY:</strong></p>
  
  <pre><code>AUTH_USER_MODEL = 'auth.User'
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>FULL ERROR TRACEBACK:</p>
  
  <blockquote>
    <p>File
    "C:\Users\Dawid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django-1.10.3-py3.5.egg\django\core\handlers\exception.py"
    in inner
      39.             response = get_response(request)</p>
    
    <p>File
    "C:\Users\Dawid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django-1.10.3-py3.5.egg\django\core\handlers\base.py"
    in _get_response
      187.                 response = self.process_exception_by_middleware(e, request)</p>
    
    <p>File
    "C:\Users\Dawid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django-1.10.3-py3.5.egg\django\core\handlers\base.py"
    in _get_response
      185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)</p>
    
    <p>File
    "C:\Users\Dawid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django-1.10.3-py3.5.egg\django\views\generic\base.py"
    in view
      68.             return self.dispatch(request, *args, **kwargs)</p>
    
    <p>File
    "C:\Users\Dawid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django-1.10.3-py3.5.egg\django\views\generic\base.py"
    in dispatch
      88.         return handler(request, *args, **kwargs)</p>
    
    <p>File "C:\Users\Dawid\PycharmProjects\Zadanie\strona\views.py" in post
      97.                 newuser.user = request.user</p>
    
    <p>File
    "C:\Users\Dawid\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django-1.10.3-py3.5.egg\django\db\models\fields\related_descriptors.py"
    in <strong>set</strong>
      211.                     self.field.remote_field.model._meta.object_name,</p>
    
    <p>Exception Type: ValueError at /index/register/ Exception Value: Cannot
    assign "&lt; SimpleLazyObject:  >": "SUser.user" must be a "User" instance.</p>
  </blockquote>
  
  <p>Please could someone help me out? 
  Kind regards.</p>