3 horizontal lines, burger
3 horizontal lines, burger

3 horizontal lines, burger
Remove all
LOADING ...

Django middleware for managing the BTCPay donation links

Clock
13.03.2026
/
Clock
16.03.2026
/
Icon of app type
Django app
An eye
87
Hearts
0
Connected dots
0
Connected dots
0
Connected dots
0

Kind of Django app:
Middleware

Examples

Description

This application helps manage all donation links generated on your own Bitcoin node, based on BTCPay Server. It has minimal installation requirements, is managed via database entries, and is easily hosted and placed on your website.
django-btcpay-donation is a Django application designed to help you easily track and manage generated links on a BTCPay Server for use via invoices. It allows you to centrally store links, group them by location, and switch between different configurations through the Django admin panel, automatically injecting active links into your template context.
All location IDs I'm writing in upper case, but it doesn't really matter. You can write them as you wish, i.e. lower_case, CamMelCase or whatever.

Features

  1. URL Management Save and automatically format BTCPay URLs by overriding the domain and Store ID via Django settings.
  2. Location Grouping: Map specific donation links to physical locations on your site (e.g., "SIDEBAR", "FOOTER").
  3. Flexible Configurations: Create sets of link locations and switch the "Active" set globally with a single click.
  4. Automatic Context Injection: A custom middleware provides your templates with active donation links without manual view updates.

Installation and Set up

Install the package via pip:
pip install django-btcpay-donation
Then you need to update the settings.py file, add the app in INSTALLED_APPS:
INSTALLED_APPS = [     ...,     'django_btcpay_donation.apps.BtcpaydonationConfig',     ..., ]
Then add the middleware to your MIDDLEWARE list to enable template context injection:
 MIDDLEWARE = [     ...,     'django_btcpay_donation.middleware.BTCPayDonationMiddleware',     ..., ]
You also can define global parameters for your BTCPay Server. If they are set, the application will automatically replace the domain and store ID in any saved links to match these values:
# The domain of your BTCPay Server BTCPAY_DOMAIN = "https://btc-node.of.by" # Your specific Store ID BTCPAY_STORE_ID = "YourStoreID"
There is only one thing left, and it is database migration:
python manage.py makemigrations python manage.py migrate

Usage

Set up locations in templates

First of all, you need to select and insert code snippets into your website structure. That is whenever you want to be able to see a donation button. It is important to note that this package did not provide any default templates to display any button, so you need to create one on your own.
And then use it like this:
{% if isBTCPayDonationMiddlewareConnected %}   {% for location in donation_link_locations %}     {% if location.linklocation_name == "FOOTER" %}       <a href="">         Donate       </a>     {% endif %}   {% endfor %} {% endif %}
Please note that "FOOTER" is just a definitive name to know where this button will appear. You can type any name as you wish and as you think is necessary.
Or if you wish to add some default fallback if there is no location added:
{% load checkLocation %} {% if isBTCPayDonationMiddlewareConnected %} {% with location=donation_link_locations|checkLocation:"MAIN-ABOVE-THE-FOLD" %} {% if location %} <a href=""> {% trans "Или поддержать проект" %}> </a> {% else %} <a href="/en/"> {% trans "Или вернуться на главную" %} </a> {% endif %} {% endwith %} {% else %}
And do not forget to load the checkLocation template tag, shipped with the package.
Let's just discuss the flow of how to add new donation buttons in your Django app. First of all, always check if middleware is connected in the first place, that is, isBTCPayDonationMiddlewareConnected. Then use the automatically added in the template context the donation_link_locations.
When looping through, via the for tag or using the template tag checkLocation, it doesn't matter. You will obtain a location object with two properties:
  1. link - actual saved link
  2. linklocation_name - a location name to check

Records and model configuration

Now, you have all the needed locations set up, and then you need to create a configuration links, and the link's location. To do this, log in to your admin panel and:
  1. BTCPayDonationLink: Add your raw BTCPay invoice URLs.
  2. BTCPayDonationLinkLocation: Assign links to specific named locations (e.g., FOOTER).
  3. BTCPayDonationConfiguration: Create a named group of locations. Plus select created locations
  4. BTCPayDonationCurrentConfiguration: Select which configuration is currently "Live" on the site.
Everything is set up and configured, and you must see immediate results, that is, donation links pointing to invoices.

URL Logic

When a BTCPayDonationLink is saved, the application parses the URL:
  1. It replaces the host with BTCPAY_DOMAIN if configured.
  2. It updates the storeId query parameter with BTCPAY_STORE_ID if configured.
  3. This ensures that even if you migrate your BTCPay Server or change stores, you only need to update your settings.py.

Similar tools

Django application for managing ad blocks from YAN

Creation date
09.10.2025
/
Update date
08.03.2026
/
Icon of app type
Django app
An eye
320
Hearts
0
Connected dots
0
Connected dots
2
Connected dots
0
Complete guide to installing and configuring Django Yandex Ad Manager for advanced advertising integration. Learn to implement banners, full-screen ads, carousels, and in-image ads with platform targeting, pagination support, and smart middleware injection. Step-by-step setup with code examples for optimal ad placement and monetization.

Breadcrumbs for Django website

Creation date
27.04.2025
/
Update date
12.02.2026
/
Icon of app type
Django app
An eye
558
Hearts
1
Connected dots
0
Connected dots
0
Connected dots
0
This tool is a Django application that generates "Breadcrumbs" of the page it is installed on. Due to the peculiarity of the Django framework, all generation occurs on the server, i.e. SSR rendering method.

Generator of table of contents for Django website’s articles

Creation date
25.04.2025
/
Update date
12.02.2026
/
Icon of app type
Django app
An eye
548
Hearts
0
Connected dots
0
Connected dots
0
Connected dots
0
This tool is a Django application that generates the "Table of contents" of the page on which it is installed. Due to the peculiarity of the Django framework, all generation occurs on the server, that is, the SSR rendering method. This application also creates anchor links to the collected chapters, if the heading have an id attribute.

Do not forget to share, like and leave a comment :)

Reviews

(0)

captcha
Send
LOADING ...
It's empty now. Be the first (o゚v゚)ノ