Mentions
Mentions lets you add Webmention functionality to any Django model with minimal setup. There is an implementation running at https://django-wm.dev/ with source code available here.
Installation
PyPI: django-wm
pip install django-wm
Setup
Celery
Mentions uses Celery and RabbitMQ for running tasks asynchronously. If you do not use them already you will need to set them up first.
System:
sudo apt install rabbitmq-server # Create user for celery service and make sure it can access your database # e.g: sudo useradd -N -M --system -s /bin/bash celery sudo usermod -a -G www-data celery # Run celery sudo -u celery env/bin/celery -A projectname worker &
Project:
Add
celery.pyto your root project. For an example implementation see celery.py from the example project.
Project code
Root project
settings.py:Set
DOMAIN_NAME:DOMAIN_NAME = 'your.url.here' # e.g. 'django-wm.dev'
Add “mentions” to
INSTALLED_APPS:INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.flatpages', 'django.contrib.sites', ... 'mentions', ]Add :code:’mentions.middleware.WebmentionHeadMiddleware’ to
MIDDLEWARE:MIDDLEWARE = [ ... 'mentions.middleware.WebmentionHeadMiddleware', ]
Root project
urls.pyurlpatterns = [ ... path('webmentions/', include('mentions.urls')), ]Include
MentionableMixinin the model(s) you want to support webmention functionality.IMPORTANT: Any models that include the mixin must also implement
all_textandget_absolute_urlmethods:from mentions.models.mixins.mentionable import MentionableMixin ... class MyModel(MentionableMixin, models.Model): ... def all_text(self) -> str: return f'{self.introduction} {self.content}' def get_absolute_url() -> str: return reverse('app.views.name', kwargs={'slug': self.slug})Update database tables:
python manage.py makemigrations python manage.py migrate
Optional Settings
Add these keys to your project settings.py to alter default behaviour.
WEBMENTIONS_AUTO_APPROVE=bool(default:False)
True: Received webmentions are automatically approved and may be publicly visible.
False: Received webmentions require manual approval before they can be made public.
Release files for django-wm 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-wm-1.0.3.tar.gz | 32.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_wm-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.2 kB
Release files / django-wm-1.0.3.tar.gz
| Download URL | django-wm-1.0.3.tar.gz |
|---|---|
| Size | 32.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd361e8e8f1f72cddc078dd75d1148da5af32a3c3120b244f708134f95d92239
|
|
BLAKE2b-256 checksum How to use checksums |
585349c2ad1e0793d75988fce1d3a1844af49e9ee9891b1a94cef161a3152bd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1
|
Release files / django_wm-1.0.3-py3-none-any.whl
| Download URL | django_wm-1.0.3-py3-none-any.whl |
|---|---|
| Size | 40.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
64f593a00415909010a41a280627cfdbd73bb3f7f1d683ab907aea896c25fcbe
|
|
BLAKE2b-256 checksum How to use checksums |
9e0e342c6bfc607c1ac898d1ffa755e626cc5bbbbcaed8ea14f6abbe4ec6ed5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.1
|