A Wagtail app to automatically log and/or manually create of redirects for 404 pages from within Wagtail admin panel.
Project description
Managed 404 Pages with Redirects
Description
A Wagtail package which will give you ability to automatically log and create of redirects from within Wagtail admin panel.
Features
- Automatic "404 Not Found" HTTP Error Detection Following the Non-Existent Page Opening
- Support for Redirects to Wagtail Pages
How It Works
Regular Expression → Regular Expression[currently in development]Regular Expression → URLRegular Expression → Wagtail PageURL → URLURL → Wagtail Page
Repository inspired by / based on a fork of:
- wagtail_managed404 - abandoned in 2018
- django-regex-redirects.
Both projects were similar (one Model class and fairly uncomplicated Middleware), so the easiest thing was simply to combine them, and work onwards from this base.
Below, you can see the classes comparison of those two.
| Django Regex Redirects | Wagtail Managed 404 (Cjk404) |
|---|---|
class Redirect(models.Model) |
class PageNotFoundEntry(models.Model) |
• old_path |
• url |
• new_path |
• redirect_to_url or redirect_to_page |
• regular_expression |
- |
• fallback_redirect |
- |
• nr_times_visited |
• hits |
Testing
Use either Django test runner (python manage.py test cjk404) or pytest.
Dependencies
- wagtail.contrib.modeladmin (https://docs.wagtail.io/en/stable/reference/contrib/modeladmin/index.html)
This package is used for the admin panel itself.
Screenshots
"All Redirects" in the Backend
"Edit Redirect" in the Backend
Usage
Fresh install
-
Get the app from PyPI:
pip install wagtail-cjk404 -
Add 'cjk404' to the INSTALLED_APPS:
INSTALLED_APPS = [
...
'wagtail.contrib.modeladmin', # required dependency
'cjk404'
...
]
- Add the supplied middleware. You may also want to disable Wagtail's default
RedirectMiddleware:
MIDDLEWARE = [
'cjk404.middleware.PageNotFoundRedirectMiddleware',
# "wagtail.contrib.redirects.middleware.RedirectMiddleware",
]
- Run the migrations:
python manage.py migrate
- Visit the Wagtail admin area. You should see any 404s recorded in the application, and you can add redirects to them. You can also add your own redirects, e.g. based on regexp.
Upgrade from the old (dj-apps-cjk404) version
- Remove folder
apps/cjk404with all contents - Change 'apps.cjk404' to 'cjk404' in INSTALLED_APPS.
- Get the app from PyPI: ```pip install wagtail-cjk404``
- You're done!
Development
Utility scripts - testing
Assuming you have Django>=4.0 and Wagtail>=3.0 pip-installed in your virtual environment, you do not need to set up a new Django/Wagtail project to develop/test the app.
After you git clone the repository, use load_tests.py to call boot_django and then to execute the unit tests.
Authors
Github URL
Old URL:
https://github.com/cjkpl/dj-apps-cjk404
New URL:
https://github.com/cjkpl/wagtail-cjk404
Please migrate your local repositories to the new URL by executing:
$ git remote set-url origin https://github.com/cjkpl/wagtail-cjk404
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail-cjk404-23.7.1.tar.gz.
File metadata
- Download URL: wagtail-cjk404-23.7.1.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b774e530bbb63be0a89b7cd9c8d47a8770abe061b4a8a5a8f9c3736f42ff254c
|
|
| MD5 |
882feb814e6a68540b452e395104588c
|
|
| BLAKE2b-256 |
5b68ce3b2133ca7304feca1088b2ee0e1050ed3de00783f7e3fbccc5187bec0c
|
File details
Details for the file wagtail_cjk404-23.7.1-py3-none-any.whl.
File metadata
- Download URL: wagtail_cjk404-23.7.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65f09017ee10a0e34079cd00f456c492b99696cc7d8cbb0691da43101c844ec3
|
|
| MD5 |
a7cb1a5bfc6073e53af7893b67bb38e3
|
|
| BLAKE2b-256 |
eba817b5e7f0f4afc0757425128c3e83bb86fe189fef7bf5cc5671e2826e81fa
|