Wagtail links provides a consistent way to refer to links in a wagtail page.
Project description
Purpose
Wagtail links has two goals:
Provide a consistent way to refer to links, which may be of different types, so as to reduce decision fatigue
Minimize broken links as much as possible.
Install
Install wagtail-links via Pip.
pip install wagtail-links
Add wagtail_links to your Django project’s INSTALLED_APPS setting.
Run database migrations.
python manage.py migrate
Usage
Add a foreign key to the page you wish to add links to.
my_link = models.ForeignKey(
'wagtail_links.Link',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
Neat:
You may use it like:
<a href="{{ self.link.url }}">Link here</a>
From a template, you can also load a link by its name:
{% load get_wagtail_link_url from wagtail_links %}
<a href="{% get_wagtail_link_url 'my-link' %}">Link here</a>
This is useful for global page links, navigation, etc.
Validation and logging
The Link model will validate that one and only one field is set. It will also disallow invalid Django reverse view names.
If a URL cannot be determined, we’ll log the issue as a warning. We won’t throw an exception as that would be bad for users. You are responsible for capturing this log warning, perhaps using Sentry.
For example - let’s say you make a Django view name called admin:index. This would typically give you /admin/. Later the admin application is removed from the program, now this link fails. It will now display “” and generate a warning in your server logs.
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 wagtail_links-2.7.0.tar.gz
.
File metadata
- Download URL: wagtail_links-2.7.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9545a7f23ff6ba7dbf27a571cf9660e3a94dcf35132e3361ec16967ac7e807a9 |
|
MD5 | e946d46cea4cba407edb93c8213c8057 |
|
BLAKE2b-256 | 304ff7797cc8493c36621d2da331879b99d18b071ce590ae8f145fc14ed6ff04 |
File details
Details for the file wagtail_links-2.7.0-py3-none-any.whl
.
File metadata
- Download URL: wagtail_links-2.7.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af530d53dfefd1434a4195c97f4d00266df46c8c551829bc813bfeadc470162b |
|
MD5 | a43d0159540513ba8f6c4e963ebaef6e |
|
BLAKE2b-256 | aff438862e56ed5142936d016f1e8b1a73aa0b9ebc12c96122cd8f005ad72892 |