Package: django-emailuser
#emailuseris a Django Custom User Module#Package Version: 1.xemailusermakes it easy to use email address as your identification token instead of a username.
emailuser is a custom Django user model (extendsAbstractBaseUser) so it takes a tiny amount of effort to use.The only difference between emailuser and the vanilla DjangoUseris email address is theUSERNAME_FIELD(and username also exist, If you not give it increate_userit will generate arandom 12 char unique string as username).emailuser supports Django 2.* to 3.*When to use emailuser ?When you need email as username in django project.Why I have created emailuser?I have created this custom user package for my university final project where I need to create user using university email also all user must have a profile link using unique username.I think this package can help me in other application development also it can help other people too. That is why I published it.
If you love it you candonate.Install and setupInstall withpip:#Django 2.x, or 3.x

  pip install django-emailuserAddemailuserto yourINSTALLED_APPSsetting:INSTALLED_APPS = [
      ...
      'emailuser',
  ]Specify the custom model as the default user model for your project using theAUTH_USER_MODELsetting in your setting:AUTH_USER_MODEL = "emailuser.User"Run migrations (Don't do any migrate beforeemailusermakemigrations).if you have tables referencing DjangoUsermodel, you will have to delete those table and migrations, then re-migrate. This will ensure everything is set up correctly from the beginning.python manage.py makemigrations emailuser
 python manage.py migrateInstead of referring to User directly, you should reference the user model usingdjango.contrib.auth.get_user_model()When you define a foreign key or many-to-many relations to theUsermodel, you should specify the custom model using theAUTH_USER_MODELsetting.from django.conf import settings
from django.db import models

class Profile(models.Model):
    user = models.ForeignKey(
        settings.AUTH_USER_MODEL,
        on_delete=models.CASCADE,
)7: For Django Rest Frameworkfrom django.contrib.auth import get_user_model
class  UserSerializer(serializers.ModelSerializer):
  class  Meta:
    model = get_user_model()
    fields = ('id', 'email', 'username', 'first_name', 'last_name')8: Helper Functionsfrom django.contrib.auth import get_user_model

get_user_model().objects.get_full_name()  # Return Full Name

/*
For sending email you must configure smtp setting like below
  EMAIL_HOST = 'hostname'
EMAIL_PORT = port
EMAIL_HOST_USER = 'username'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True*/get_user_model().objects.send_email(subject, message, from_email)this will send email to logged in userby default it will not show sending errorfor showing error extra False argument required like belowget_user_model().objects.send_email(subject, message, from_email, False)9: Registraionget_user_model().objects.create_user(email, password, first_name, last_name, username)
#username field is optional. If it's empty a rendom unique username will be created10: Login#Required argument
email and passwordNote.FOO@example.comwill be replaced tofoo@example.comautomaticallyLicenseReleased under the MIT license. SeeLICENSEfor details.Questions, comments, or anything else?ContributeOpen an issuehttps://www.linkedin.com/in/swe-himelranacontact@himelrana-swe.comGive a thanks byDonation