# wagtail-links
## 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.
```sh
pip install wagtail-links
```
Add `wagtail_links` to your Django project's `INSTALLED_APPS` setting.
Run database migrations.
```sh
python manage.py migrate
```
## Usage
Add a foreign key to the page you wish to add links to.
```py
my_link = models.ForeignKey(
'wagtail_links.Link',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
```
Neat:
![](admin.png)
You may use it like:
```html
<a href="{{ self.link.url }}">Link here</a>
```
From a template, you can also load a link by its name:
```html
{% 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.
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/thelabnyc/wagtail-links",
"name": "wagtail-links",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": null,
"author": "thelab",
"author_email": "thelabdev@thelab.co",
"download_url": "https://files.pythonhosted.org/packages/95/bd/ed65657151df0c537c42d3de13ccd268da7b9df5021f3f660cd227163ac0/wagtail_links-2.10.0.tar.gz",
"platform": null,
"description": "# wagtail-links\n\n## Purpose\n\nWagtail links has two goals:\n\n- Provide a consistent way to refer to links, which may be of different types, so as to reduce decision fatigue\n- Minimize broken links as much as possible.\n\n\n\n## Install\n\nInstall wagtail-links via Pip.\n\n```sh\npip install wagtail-links\n```\n\nAdd `wagtail_links` to your Django project's `INSTALLED_APPS` setting.\n\nRun database migrations.\n\n```sh\npython manage.py migrate\n```\n\n\n## Usage\n\nAdd a foreign key to the page you wish to add links to.\n\n```py\nmy_link = models.ForeignKey(\n 'wagtail_links.Link',\n null=True,\n blank=True,\n on_delete=models.SET_NULL,\n related_name='+'\n)\n```\n\nNeat:\n\n![](admin.png)\n\nYou may use it like:\n\n```html\n<a href=\"{{ self.link.url }}\">Link here</a>\n```\n\nFrom a template, you can also load a link by its name:\n\n```html\n{% load get_wagtail_link_url from wagtail_links %}\n\n<a href=\"{% get_wagtail_link_url 'my-link' %}\">Link here</a>\n```\n\nThis is useful for global page links, navigation, etc.\n\n\n## Validation and logging\n\nThe Link model will validate that one and only one field is set.\nIt will also disallow invalid Django reverse view names.\n\nIf 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.\n\nFor 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.\n\n",
"bugtrack_url": null,
"license": "ISC",
"summary": "Wagtail links provides a consistent way to refer to links in a wagtail page.",
"version": "2.10.0",
"project_urls": {
"Homepage": "https://gitlab.com/thelabnyc/wagtail-links",
"Repository": "https://gitlab.com/thelabnyc/wagtail-links"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cf74ad739f5e33daef1025a43c01764389a8b2748ba0a0b15b2de6f3d6b807a1",
"md5": "9a727f061a1ba46eec8857a8f011f130",
"sha256": "10ebbc28d2c5b3ff34499976b187665920059d147e03838df24cc72317e9c38d"
},
"downloads": -1,
"filename": "wagtail_links-2.10.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9a727f061a1ba46eec8857a8f011f130",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 15001,
"upload_time": "2024-11-01T18:42:17",
"upload_time_iso_8601": "2024-11-01T18:42:17.919148Z",
"url": "https://files.pythonhosted.org/packages/cf/74/ad739f5e33daef1025a43c01764389a8b2748ba0a0b15b2de6f3d6b807a1/wagtail_links-2.10.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "95bded65657151df0c537c42d3de13ccd268da7b9df5021f3f660cd227163ac0",
"md5": "1b4013edec3c0b633d6643e771bc1b1d",
"sha256": "88db8acc26b577c8c6160ff601f70c78407e78c52bd2e87f4d59d78c063cf685"
},
"downloads": -1,
"filename": "wagtail_links-2.10.0.tar.gz",
"has_sig": false,
"md5_digest": "1b4013edec3c0b633d6643e771bc1b1d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 9224,
"upload_time": "2024-11-01T18:42:19",
"upload_time_iso_8601": "2024-11-01T18:42:19.280648Z",
"url": "https://files.pythonhosted.org/packages/95/bd/ed65657151df0c537c42d3de13ccd268da7b9df5021f3f660cd227163ac0/wagtail_links-2.10.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-01 18:42:19",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "thelabnyc",
"gitlab_project": "wagtail-links",
"lcname": "wagtail-links"
}