Skip to main content
#DJANGO-RELINKING

Django-relinking application adds function and template filter for relinking custom text.


Installation
------------------------
1. Run from command line "pip install django-relinking"
2. Add "django_relinking" to INSTALLED_APPS in your settings package
3. Run migrations: ``` python manage.py migrate django_relinking ```

Options
------------------------
_If you want you can redefine next options:_
+ __RELINKING_LINK_TEMPLATE__ - template for link tag.
*Default*: ```RELINKING_LINK_TEMPLATE = '<a target="{target}" href="{url}">{text}</a>'```
+ __RELINKING_ENABLE_CACHE__ - enable or disable caching.
*Default*: ```RELINKING_ENABLE_CACHE = False```
+ __RELINKING_CACHE_PREFIX__ - prefix for keys in cache.
*Default*: ```RELINKING_CACHE_PREFIX = "{links_table}.{hash}"```
+ __RELINKING_INDEX_PATTERN__ - temporary pattern for replacting keys to link indexes.
*Default*: ```RELINKING_INDEX_PATTERN = "<%=link {}=%>"```

Usage
------------------------
*Before usage you must register models or other objects which have ```get_absolute_url``` method:*
```python
from django_relinking.content_types import register

"""
content_type - class of model or view which has method 'get_absolute_url`

verbose_name - human title of content type.
--- verbose_name can be a function. Default is None.
--- If verbose_name is None and content_type has attribute 'verbose_name',
------ then verbose_name = content_type.verbose_name
--- If verbose_name is None and content_type has method 'verbose_name',
------ then verbose_name = content_type.verbose_name()
--- If verbose_name is None and content_type hasn't attribute 'verbose_name'
------ then verbose_name = content_type.__name__

objects - queryset or list of this content_type objects.
--- For example: ``` Model.objects.all() ```.
--- Every objects must have attribute pk and `get_absolute_url` method
--- If objects is None - this content type is a single
--- and it must have `get_absolute_url` method
"""
register(content_type, verbose_name, objects)
```

*Also you can:*
```python
from django_relinking.content_types import register_all, unregister, unregister_all
#
# Register many content types for one time
register_all(content_type1, content_type2, ..., content_typeN)
#
# Unregister registered content type
unregister(content_type)
#
# Unregister all registered content types
unregister_all()
#
# Unregister some registered content types
unregister_all(content_type1, content_type2, ..., content_typeN)
```
____________________________________________________
When you register appropriate content types you can:
____________________________________________________
**In template:**
```html
{% load relinking %}
<!-- Plain text -->
{% filter relink %}
plain text
{% endfilter %}
<!-- variable -->
{{ model.attr|relink }}
```
**In code:**
```python
from django_relinking import relink_text
relinked = relink_text(some_text_with_keywords)
```

Metadata

Release files for django-relinking 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-relinking 0.0.2
File Size Uploaded Provenance Actions
django-relinking-0.0.2.tar.gz 8.3 kB Without provenance Details for django-relinking-0.0.2.tar.gz

Release files / django-relinking-0.0.2.tar.gz

Download URL django-relinking-0.0.2.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e0276fba110568f340595f6d9a5c66ffe1e1573066ff76e65019d590cf54190f
BLAKE2b-256 checksum
How to use checksums
b693d20339e807b217f2d205c3c8f72d44c32d3fe7e244e4ab42d83199fb7c9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-relinking 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page