title: Django case insensitive login, mixed case username
body: <p>I'm trying to do case insensitive login for a Django app, without altering original username case. According to my research, the best approach is to create a related field to store the username in lowercase at registration. No reinventing the user model, it's a simple solution, right? My dilemma: How to do you take data from one model, change it, and save it in another model when the object is created?</p>
  
  <p>Here is what is in <strong>models.py</strong>:</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  
  class UserProfile(models.Model):
      user = models.OneToOneField(User)
      lc_n = User.username
      lc_n = lc_n.lower()
      lowercase_name = models.CharField(max_length=30, default=lc_n)
  </code></pre>
  
  <p>When running <code>python manage.py makemigrations</code> there is the following error:</p>
  
  <p><code>AttributeError: type object 'User' has no attribute 'username'</code></p>
  
  <p>User does have that attribute, but it can't be accessed this way.</p>
  
  <p>Please forgive me, as this must contain some simple fundamental flaw. Any support that may be offered will be greatly appreciated.</p>