title: UNIQUE constraint failed: auth_user.username
body: <p>I'm trying to store the First name and last name straight from the Facebook API to a User Auth model (which is extended with FacebookProfile model, containing webpull, id and year_formed)</p>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class FacebookProfile(models.Model):
      user = models.OneToOneField(User, on_delete = models.CASCADE)
  
  
      id = models.PositiveIntegerField(primary_key = True)
      #name = models.CharField(max_length = 200, null = True)
      year_formed = models.PositiveIntegerField(default = 0)
      webpull= models.CharField(max_length =1000, null = True)
  </code></pre>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code>if request.method == 'GET':
      print 'im here'
  
      return render(request, "logV2.html")
  if request.method == "POST":
      first_name = request.POST.get('first_name')
      last_name = request.POST.get('last_name')
      print first_name, last_name
  
      facebook_user = FacebookUserForm(data=request.POST)
      facebook_profile = FacebookProfileForm()
  
      has_account = authenticate(first_name = first_name, last_name = last_name)
  
      if has_account:
          print 'this has account'
          login(request, has_account)
          return HttpResponseRedirect('/music/home/')
      else:
          id_ = request.POST.get('id')
          birthday = request.POST.get('year_formed')
          webpull = request.POST.get('webpull')
  
          if birthday == "undefined":
              print 'im emplty'   
              year_formed = random.randint(1993,1998)
          else:
              year_formed = re.findall(r"[0-9][0-9][0-9][0-9]$", birthday)[0]
  
          print id_, year_formed, webpull
  
          print facebook_user
  
          user = facebook_user.save()
          profile = facebook_profile.save(commit = False)
          profile.user = user
          profile.webpull = webpull
          profile.id = id_
  
          ## steal birtday fucntion from log 
          # move to new database facebook (neeed to change all artists to facebookprofile)
          profile.year_formed = year_formed
          profile.save()
  
  
  
          #authenticate user. then log him in.
          #user = authenticate(username = profile.user.username)
          now_has_account = authenticate(first_name = first_name, last_name = last_name)
          login(request, now_has_account)
  
  
          #profile.save()
          return HttpResponseRedirect('/music/home/')
  </code></pre>
  
  <p>In the views the code brakes at <code>user = facebook_user.save()</code></p>
  
  <p>I tried clearing the whole database,</p>
  
  <p>also </p>
  
  <p>What I'm receiving from the html is a form with first_name,last_name,id,year_formed,webpull. The data gets to the backend fine. </p>
  
  <p><strong>Forms.py</strong></p>
  
  <pre><code>class FacebookUserForm(forms.ModelForm):
      class Meta:
          model = User
          fields = ('first_name', 'last_name')
  
  class FacebookProfileForm(forms.ModelForm):
      class Meta:
          model = FacebookProfile
          fields = ('id', 'year_formed', 'webpull',)
  </code></pre>
  
  <p>what im authenticating
  <strong>Auth_Backend.py</strong></p>
  
  <pre><code>class OnlynameandsurnameAuth(ModelBackend):
      def authenticate(self, first_name = None, last_name = None):
          try:
              return User.objects.get(first_name = first_name, last_name = last_name)
          except:
              return None
  </code></pre>
  
  <p>then
  <strong>auth.py</strong></p>
  
  <pre><code>admin.site.register(FacebookProfile)
  </code></pre>
  
  <p>the backend authentification
  <strong>settings.py</strong></p>
  
  <pre><code>AUTHENTICATION_BACKENDS = (
      # ... your other backends
      #'music.auth_backend.PasswordlessAuthBackend',
      'music.auth_backend.OnlynameandsurnameAuth',
  )
  </code></pre>
  
  <p>any ideas how to save the first_name and last_name without having a UNIQUE error?</p>
  
  <p>Thanks! :D</p>