Django custom user model app and django allauth for authentication
Project description
==========================
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
- 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(),
}
-
Django Allauth Used for authentication.
-
Bootstrap templates for DJANGO ALLAUTH https://bootsnipp.com/snippets/d2eZ
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
License
Donate
==================
BITCOIN: 389rzApDvz3TsKLjjTQBP9UPXM87SPD5aH
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for Django CustomUser Model-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2fb7791e79192226c4e4016e21b7ae4afd0d1be4fb6622ceb86f78d20211767 |
|
MD5 | cf5a7f212aed9b6969a132be4a3e6490 |
|
BLAKE2b-256 | ce34c9b19f2cf469f41f203991b24ce7d829c081e91e03473d4b77d48e22e6e6 |
Hashes for Django_CustomUser_Model-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d8166adb080c967950c53f1a44bdaf9b5d0bc10c0861e25b8580edd912a6eb3 |
|
MD5 | ae16e5dd1e825e1eeeaca1ff4bb828d4 |
|
BLAKE2b-256 | e8804aa295aee4f4cc1d9ac8679a108d9f77d237425bae16f6d3cba2faa52682 |