class MyUser(AbstractBaseUser, PermissionsMixin): .... is_staff = models.BooleanField('staff status', default=False, help_text='Designates whether the user can log into this admin ' 'site.') is_active = models.BooleanField('active', default=True, help_text='Designates whether this user should be treated as ' 'active. Unselect this instead of deleting accounts.') def get_full_name(self): full_name = '%s %s' % (self.first_name, self.last_name) return full_name.strip() def get_short_name(self): return self.first_name
just to retain what could already be apart of Django. You guys know more about Django then I ever will and what the best way is to go about it but if we can eliminate additional code that is already in Django that would be wonderful.
Now in referencing:
Basically what I'm saying is, we shouldn't have to do what this fellow had to do:
Unfortunately there's nothing within django.contrib.auth that you can simply subclass to get a model that has
email address in place of user name and
works nicely with other django.contrib.auth-stuff, like groups.
The simplest approach is to copy models.py, admin.py and forms.py fromdjango.contrib.auth, rip out user name all over the place and put in email address in it's place. I've done just that and I'm using it successfully in a couple of client projects.
I've put it up on github and pypi so you can install it with
pip install django-libtech-emailuser
I thank you for your time and I appreciate your consideration for integrating this once and for all into Django.
JJ Zolper
class CustomUser(AbstractBaseUser, PermissionsMixin):
....
email = models.EmailField(max_length=255, unique=True)
....
objects = CustomUserManager()
USERNAME_FIELD = 'email'Russell Keith-Magee,Are you the one who is doing "Getting Started With Django" ? Sorry for getting off topic but just was curious. If so I donated money to that project and I am glad you are doing it.
Yes, that's what it seems to be called by other Django devs, "Email address as username." I prefer more to think of it as just "Email" with the same exact login handlign as "Username." That's my goal with this post is keep pushing until the point is reached where we can just call it "Email" login. I also think it is such a common case that it should be within Django's core. It is obvious from the large number of posts online about replacing the username with an email.
If you have heard Jacob discussing it before, that would be wonderful! It would be awesome if the Django guys accepted this into Django all together. Given it must be considered with the release of Django 1.5 they did give a lot more support to people like me trying to have the email as the username through things like:class CustomUser(AbstractBaseUser, PermissionsMixin): .... email = models.EmailField(max_length=255, unique=True) .... objects = CustomUserManager() USERNAME_FIELD = 'email'So maybe Jacob and Adrian are already on top of this.
The only thing I have been trying to do is follow the suggestions of those posts I have found online. I could surely route some possible people I think might have already banged this out but I'm not sure I'm the best bet. However, I did go ahead and open a ticket:Thanks again to all the Django developers for their hard work,