title: Django - User creation with custom user model results in internal error
body: <p>Ok, I know this is a silly question but I am blocked and I can't figure out what to do.</p>
  
  <p>I have searched on google and stackoverflow but did not found any answer :
  I tried this :</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2886987/adding-custom-fields-to-users-in-django">Adding custom fields to users in django</a></li>
  <li><a href="https://stackoverflow.com/questions/11488974/django-create-user-profile-on-user-creation">Django - Create user profile on user creation</a></li>
  <li><a href="https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users" rel="nofollow noreferrer">https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users</a></li>
  </ul>
  
  <p>My model is the following :</p>
  
  <pre><code>class UserProfile(models.Model):
      user = models.OneToOneField(User)
  
      quota = models.IntegerField(null = True)
  
  
  def create_user_profile(sender, instance, created, **kwargs):
      if created:
          UserProfile.objects.create(user=instance)
  
  post_save.connect(create_user_profile, sender=User)
  </code></pre>
  
  <p>And my view for user registration is the following : </p>
  
  <pre><code>def register(request):
      if request.method == 'POST': # If the form has been submitted...
          form = RegistrationForm(request.POST) # A form bound to the POST data
          if form.is_valid(): # All validation rules pass
              # Process the data in form.cleaned_data
              cd = form.cleaned_data
  
              #Then we create the user
              user = User.objects.create_user(cd['username'],cd["email"],cd["password1"])
  
              user.get_profil().quota = 20
  
              user.save()
  
              return HttpResponseRedirect('')
  
      else:
          form = RegistrationForm() # An unbound form
  
      return render(request, 'registration_form.html', {'form': form,})
  </code></pre>
  
  <p>The line that launches an InternalError is :</p>
  
  <pre><code>user = User.objects.create_user(cd['username'],cd["email"],cd["password1"])
  </code></pre>
  
  <p>And the error is :</p>
  
  <pre><code>InternalError at /register/
  
  current transaction is aborted, commands ignored until end of transaction block
  </code></pre>
  
  <p>Thank you for your help</p>