A plugin for DJ Press that publishes new posts to Mastodon.
Project description
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.
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
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_SETTINGS
insettings.py
:DJPRESS_SETTINGS = { # ... existing settings "PLUGINS": [ # ... existing plugins "djpress_publish_mastodon", ] }
-
Add the plugin settings to your
DJPRESS_SETTINGS
insettings.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 } } }
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")
- 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.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file djpress_publish_mastodon-1.0.1.tar.gz
.
File metadata
- Download URL: djpress_publish_mastodon-1.0.1.tar.gz
- Upload date:
- Size: 13.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c887da73dd811aaeb2fa69bb10aad53d890986ef443d72c06131f5446eb8ff2d |
|
MD5 | 8f93e658897ab6d467169b6566851b23 |
|
BLAKE2b-256 | fdc8850745203a9491accbcf422041f8aed287f744896303b98bcc965b6cae25 |
File details
Details for the file djpress_publish_mastodon-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: djpress_publish_mastodon-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07d8b0fa5e8be15509f975320b4a9cb1221962dd3189298fa1dbad13dca232f6 |
|
MD5 | 72c3b6bb3154902091d65c9502f485ce |
|
BLAKE2b-256 | 4a0fc38d8c6b7dfeb24944becf2f035bbe2f892a0307d5472791028cc314384f |