Skip to main content

==========================

Django Custom User Model App + Django Allauth

==========================

Django custom user model app integrated with Django Allauth Integrated set of Django applications addressing authentication, registration, account management as well as 3rd party (social) account authentication.

Home page https://www.ghorz.com/blog/Apps/2020-03-20/21/django-custom-user-model-app-and-django-allauth/

FEATURES

  • Custom User Model

    • Fields
    • email
    • first_name
    • last_name
    • middle_name
    • photo - ImageField

    NOTE: username field is not included.

  • Methods

    • get_full_name() - return first_name, middle_name and last_name
    • get_short_name() - returns first_name and last_name
    • get_user_profile() - returns JSON data comprising
      {
      'email': self.email,
      'first_name': self.first_name,
      'last_name': self.last_name,
      'middle_name': self.middle_name,
      'photo': self.photo,
      'is_active': self.is_active,
      'is_staff': self.is_staff,
      'is_superuser': self.is_superuser,
      'last_login': self.last_login,
      'date_joined': self.date_joined,
      'full_name': self.get_full_name(),
      'short_name': self.get_short_name(),
      }

REQUIRED APPS

  • pip install django-allauth
  • pip install Django>=2.2
  • pip install django-bootstrap4

INSTALLATION

==================

 settings.py
 #BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
 MEDIA_DIR = os.path.join(BASE_DIR, 'media')
 STATIC_DIR = os.path.join(BASE_DIR, 'static')


 INSTALLED_APPS = [
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',
     'django.contrib.messages',
     'django.contrib.staticfiles',
     'django.contrib.sites', # external

     # THIRD PARTY
     'bootstrap4',

     # DANGO ALLAUTH
     'allauth',
     'allauth.account',
     'allauth.socialaccount',

     # USER APP
     'user_app',
 ]
 SITE_ID = 1


 TEMPLATES = [
     {
         'BACKEND': 'django.template.backends.django.DjangoTemplates',
         'DIRS': [TEMPLATES_DIR,], ## for template dir
         'APP_DIRS': True,
         'OPTIONS': {
             'context_processors': [
                 'django.template.context_processors.debug',
                 'django.template.context_processors.request',
                 'django.contrib.auth.context_processors.auth',
                 'django.contrib.messages.context_processors.messages',
             ],
         },
     },
 ]


 #STATIC_URL = '/static/'
 MEDIA_ROOT = MEDIA_DIR
 MEDIA_URL = '/media/'
 STATICFILES_DIRS = [STATIC_DIR,]

 #Email Settings
 EMAIL_USE_TLS = True
 EMAIL_HOST = 'smtp.gmail.com'
 EMAIL_HOST_USER = 'youremail@gmail.com'
 EMAIL_HOST_PASSWORD = 'your email password'
 EMAIL_PORT = 587

 # IMPORT USER_APP SETTINGS
 from user_app.settings import *

urls.py

path('accounts/', include('allauth.urls')),

WARNING: THIS SHOULD BE YOUR FIRST MIGRATION

  • python manage.py makemigrations user_app
  • python manage.py migrate
  • python manage.py createsuperuser

OPTIONAL

  • ACCOUNT_EMAIL_VERIFICATION = 'mandatory'

DOWNLOAD BOOTSTRAP TEMPLATE

https://www.ghorz.com/media/blog/media/django_custom_user_model_templates.zip

  • uzip and use as root templates directory

License

MIT

Donate

==================

BITCOIN: 389rzApDvz3TsKLjjTQBP9UPXM87SPD5aH

Metadata

Release files for Django-CustomUser-Model 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Django-CustomUser-Model 1.1.0
File Size Uploaded
Django CustomUser Model-1.1.0.tar.gz 236.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Django-CustomUser-Model 1.1.0
File Interpreter ABI Platform
Django_CustomUser_Model-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 490.9 kB

Release files / Django CustomUser Model-1.1.0.tar.gz

Download URL Django CustomUser Model-1.1.0.tar.gz
Size 236.6 kB
Tags Source
SHA-256 checksum
How to use checksums
17b2f25e9c51a586188a47a7b58c56e41567e0250da7ee81e4981c3eebb17583
BLAKE2b-256 checksum
How to use checksums
a7a6203cba27734078c2d3f79f4b9c3560c1e41deaecdaaec1c7ab316c4b03b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

Release files / Django_CustomUser_Model-1.1.0-py3-none-any.whl

Download URL Django_CustomUser_Model-1.1.0-py3-none-any.whl
Size 254.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b1205af07a32fbb7fd9ee3e389378b0a8d7bc4f3989d4fdb0df6ff974e98e79
BLAKE2b-256 checksum
How to use checksums
0ae589903a4bb2e0ed05473ae7397ee976bd5963733c8664a53b5376d18f9c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.3

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.5

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page