[PYTHON] [Wagtail] Add a login page to the Wagtail project

Introduction

It is an output of what was learned by a web development beginner. I'm studying web development with Django ...

What is Wagtail

What is Wagtail in the first place is a content management system (CMS) built on ** Django **. Roughly speaking, you can easily create management pages such as blogs.

Try

Immediately, we will go through the steps from project creation to login page creation.

Start Wagtail project

We will proceed on the assumption that Pipenv and Virtualenv will be used.

pip install wagtail
wagtail start mysite
cd mysite
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver

You should now be able to create your Wagtail project and access the initial page below.

wagtail.jpeg

Add a login page

First, install django-allauth and enable Allauth in base.py under the mysite / settings directory.

pip install django-allauth

base.py


'django.template.context_processors.request', #to add

TEMPLATES = [
    {
        # ...,
        'OPTIONS': {
            'context_processors': [
                # ...
                'django.template.context_processors.request', #If not, add
                # ...
            ],
        },
    },
]

INSTALLED_APPS = (
    # ... other apps 
    #If not, add the following
    'django.contrib.auth', 
    'django.contrib.messages',
    'django.contrib.sites',

    'allauth',
    'allauth.account',
    'allauth.socialaccount',
    # ...
)

AUTHENTICATION_BACKENDS = ( 
   'django.contrib.auth.backends.ModelBackend',
   'allauth.account.auth_backends.AuthenticationBackend',
) #to add

#Add the following
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_CONFIRM_EMAIL_ON_GET = True
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "mandatory"
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
ACCOUNT_LOGOUT_ON_GET = True
ACCOUNT_LOGIN_ON_PASSWORD_RESET = True
ACCOUNT_LOGOUT_REDIRECT_URL = '/login/'
ACCOUNT_PRESERVE_USERNAME_CASING = False
ACCOUNT_SESSION_REMEMBER = True
ACCOUNT_SIGNUP_PASSWORD_ENTER_TWICE = False
ACCOUNT_USERNAME_BLACKLIST = ["admin", "god"]
ACCOUNT_USERNAME_MIN_LENGTH = 2

Next, set the url pattern for the login page.

urls.py


urlpatterns = [
    # .. Existing urls
    #to add
    url(r'', include('allauth.urls')), 
    url(r'', include(wagtail_urls)),
]

Finally, migrate and access the login page from http: // localhost: 8000 / login / and you're done.

python manage.py migrate

Summary

I checked the flow of creating a login page using django-allauth. The login page itself can be introduced immediately by just playing with base.py and ʻurls.py`, so you can proceed with efficient application development!

reference

LEARN WAGTAIL -HOW TO INSTALL WAGTAIL WITH DOCKER https://learnwagtail.com/tutorials/how-install-wagtail-docker/

-ADDING USER REGISTRATION/LOGIN TO YOUR WAGTAIL WEBSITE https://learnwagtail.com/tutorials/adding-user-authentication-registration-and-login-your-wagtail-website/

Recommended Posts

[Wagtail] Add a login page to the Wagtail project
[Django] How to redirect unlogged-in users to the login page
Add a dictionary to MeCab
The usual way to add a Kernel with Jupyter Notebook
Steps to create a Django project
[Selenium] Use a while statement to repeatedly move to the "next page"
Add a GPIO board to your computer. (1)
How to add a package with PyCharm
Give a title to the ipywidgets tab
In Jupyter, add IPerl to the kernel.
[NNabla] How to add a quantization layer to the middle layer of a trained model
How to test on a Django-authenticated page
Add a layer using the Keras backend
Add a Python virtual environment to VSCode
SSH login to the target server from Windows with a click of a shortcut
I want to add silence to the beginning of a wav file for 1 second
[Selenium] Go to the next page without pressing Next
Add a command to mark similar files together
Just add the python array to the json data
Add Windows to the Linux OS boot menu
How to add a Python module search path
To add a module to python put in Julialang
Save the object to a file with pickle
Wagtail Recommendation (4) Let's pass the context to the template
A python amateur tries to summarize the list ②
Create a command to get the work log
[Python] Throw a message to the slack channel
Prompt to give a synonym for each login
In Jupyter, add IPerl to the kernel.
Just add the python array to the json data
Add Windows to the Linux OS boot menu
How to add arbitrary headers to response with FastAPI
To dynamically replace the next method in python
[Wagtail] Add a login page to the Wagtail project
[NNabla] How to add a new layer between the middle layers of a pre-built network
Add a function to tell the weather of today to slack bot (made by python)
Create a function to visualize / evaluate the clustering result
How to write a GUI using the maya command
A quick introduction to the neural machine translation library
A memo to visually understand the axis of pandas.Panel
Just add the driver to the shape key with blender
Wagtail Recommendations (2) Let's define, edit, and display a page
The shortest route to get a cultural fish environment
Wagtail Recommendation (5) Let's add your own block to StreamField
Display a screen that requires login to digital signage
Steps to calculate the likelihood of a normal distribution
How to add page numbers to PDF files (in Python)
Transit to the update screen with the Django a tag
I made a command to markdown the table clipboard
[Morphological analysis] How to add a new dictionary to Mecab
Tasks at the start of a new python project
Try to decipher the login data stored in Firefox
To myself as a Django beginner (1) --Create a project app--
How to post a ticket from the Shogun API
How to reference static files in a Django project
Let's add it to the environment variable from the command ~
Generate a bash script to add Datadog monitor settings
Python Note: The mystery of assigning a variable to a variable
Deploy the management page to production to make maintenance easier.
[* CentOS 6.10] What to do if you cannot add the IUS Community Project repository on CentOS 6.5 (VirtualBox)
A Python script that goes from Google search to saving the Search results page at once