DJ Press Mastodon Publisher
A plugin for DJ Press that automatically publishes your blog posts to your Mastodon server. When you publish a new post on your Django blog, this plugin will create a corresponding post on your Mastodon account with a customizable status message.
New Feature: Now also supports micro-blogging. With this feature, you can post the full post content to your
Mastodon account instead of the status message. The use-case is that you want to post short updates to your blog
and have these posted to Mastodon as if they were posted there. There is no link back to your blog when using
this feature. Add a microblog_category setting with the category slug you use for microblog posts.
Features
- 🚀 Automatic posting to Mastodon when blog posts are published
- 📝 Customizable post message
- ✅ Keeps track of posts that have already been posted to Mastodon, so you don't get multiple Mastodon posts
- µ Micro-blogging support.
Requirements
- Python >= 3.10
- Django >= 4.2
- DJ Press >= 0.12.1
- Mastodon.py >= 1.8.1
Installation
-
Install the package using pip:
pip install djpress-publish-mastodon
-
Add the plugin to your
DJPRESS_SETTINGSinsettings.py:DJPRESS_SETTINGS = { # ... existing settings "PLUGINS": [ # ... existing plugins "djpress_publish_mastodon", ] }
-
Add the plugin settings to your
DJPRESS_SETTINGSinsettings.py:DJPRESS_SETTINGS = { # ... existing settings "PLUGIN_SETTINGS": { # ... existing plugins "djpress_publish_mastodon": { "instance_url": "https://mastodon.social", # or the instance you are using "access_token": "...", # or preferably load from an environment variable or secrets manager "status_message": "🚀 I created a new blog post!", # keep this brief "base_url": "https://example.com", # The base URL to your site "microblog_category": "microblog", # Optional setting to enable micro-blogging for a specific category slug. } } }
Configuration
Getting Your Mastodon Access Token
- Log into your Mastodon instance
- Go to Preferences > Development
- Click "New Application"
- Give it a name (e.g., "My DJ Press Blog") - this will be displayed in the toot's metadata.
- Select the following permissions:
write:statuses
- Save and copy the access token into the
DJPRESS_SETTINGS.
Usage
Once configured, the plugin works automatically. When you publish a new blog post, it will be posted to your Mastodon account using the configured message.
If you configure the microblog_category settings, posts that belong to that category will be posted to Mastodon with
the full content and no link back to the original post. Note that Mastodon does not support HTML content and it also
won't render the Markdown as rich text. In other words, any Markdown syntax you use in the post will be displayed in
the Mastodon toot as-is.
Note that a published post will only be published to Mastodon once - the first time it is saved and with
is_published = True. This plugin keeps track of which posts have been published to Mastodon and won't publish them
again. The list of published posts is stored in the plugin storage model.
Troubleshooting
If posts aren't appearing on Mastodon:
- Check the Django logs for error messages
- Verify your access token is correct
- Ensure the plugin is enabled in settings
- Confirm your Mastodon instance URL is correct
- Check that your posts are marked as published
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Distributed under the MIT License. See LICENSE for more information.
Credits
Created by Stuart Maxwell Powered by DJ Press
Release files for djpress-publish-mastodon 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| djpress_publish_mastodon-1.4.0.tar.gz | 4.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djpress_publish_mastodon-1.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.2 kB
Release files / djpress_publish_mastodon-1.4.0.tar.gz
| Download URL | djpress_publish_mastodon-1.4.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3cfb532bfe20eea947f3c4c77ddde0b3e4dcbb4a28c7af53441eb703ddc0e4e
|
|
BLAKE2b-256 checksum How to use checksums |
08e8ef3e3bead1907c17d9f0d8ee74c254f634674cb90e335e8a8b56057b02e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.27.0 CPython/3.14.5 Linux/6.17.0-1018-azure
|
Release files / djpress_publish_mastodon-1.4.0-py3-none-any.whl
| Download URL | djpress_publish_mastodon-1.4.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
847387ed7d893e2925b4b5bb619b6f7838aa0c74fa852d40288c894c94dad2b1
|
|
BLAKE2b-256 checksum How to use checksums |
e24138fed69d93b3423b651acdbf5d81a7dc57ffb5940e0fc3f817408fd8bd9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
pdm/2.27.0 CPython/3.14.5 Linux/6.17.0-1018-azure
|