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
- 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
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
File details
Details for the file Django CustomUser Model-1.1.0.tar.gz
.
File metadata
- Download URL: Django CustomUser Model-1.1.0.tar.gz
- Upload date:
- Size: 236.6 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17b2f25e9c51a586188a47a7b58c56e41567e0250da7ee81e4981c3eebb17583 |
|
MD5 | 809082e9be641a1eede3132f0bd02d3b |
|
BLAKE2b-256 | a7a6203cba27734078c2d3f79f4b9c3560c1e41deaecdaaec1c7ab316c4b03b8 |
File details
Details for the file Django_CustomUser_Model-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: Django_CustomUser_Model-1.1.0-py3-none-any.whl
- Upload date:
- Size: 254.3 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b1205af07a32fbb7fd9ee3e389378b0a8d7bc4f3989d4fdb0df6ff974e98e79 |
|
MD5 | 61dd7e7eabaac718e65c8f8b013c00cc |
|
BLAKE2b-256 | 0ae589903a4bb2e0ed05473ae7397ee976bd5963733c8664a53b5376d18f9c9f |