Skip to main content

Mentions

https://travis-ci.org/beatonma/django-wm.svg?branch=master

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.py to your root project. For an example implementation see celery.py from the example project.

Project code

  1. 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',
      ]
  2. Root project urls.py

    urlpatterns = [
        ...
        path('webmentions/', include('mentions.urls')),
    ]
  3. Include MentionableMixin in the model(s) you want to support webmention functionality.

    IMPORTANT: Any models that include the mixin must also implement all_text and get_absolute_url methods:

    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})
  4. 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)

Source distribution for django-wm 1.0.3
File Size Uploaded
django-wm-1.0.3.tar.gz 32.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-wm 1.0.3
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

4.2.0

2 release files

4.1.3

2 release files

4.1.2

2 release files

4.1.1

2 release files

4.0.4

2 release files

4.0.2

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.1.1

2 release files

3.1.0

2 release files

3.0.1

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

4 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

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