Skip to content

Instantly share code, notes, and snippets.

@RNCTX
RNCTX / django-template_partials-htmx-tables2-filter_search.md
Last active January 31, 2026 14:51
How to tie HTMX + django-tables2 + django-filters + django-template-partials together

Reasoning for this

It took me some time of digging through disparate docs and blog posts to piece together how to use django-tables2, htmx, django-template-partials, and django-filter, all at the same time in an optimal way for highly interactive data tables in django.
At present I am not using Alpine.js, another popular addition to this stack, due to my preference for writing plain ole javascript instead of having to learn another syntax, but that's really outside of this scope anyway, this is meant to be a how-to on the Python tools + HTMX.

Credit to the following blog posts and stackoverflow replies that were helpful in piecing this stuff together as a first time user of most of these Django packages:

@viktor2097
viktor2097 / README.md
Last active May 8, 2025 18:55
Dynamically add formset form with HTMX

Dynamically add additional forms for a formset using HTMX and a little bit of hyperscript

Supports deleting and adding rows.

I'm using django-template-partials, django-htmx, htmx and hyperscript

I decorate my views with the @htmx_dynamic_handler decorator. This decorator allows you to specify the action that triggers the HTMX request and the function that renders the partial.

@htmx_dynamic_handler("action", _function_that_renders_a_partial)
.progress {
position: fixed;
top: 0;
z-index: 1000;
height: 4px;
width: 100%;
border-radius: 2px;
background-clip: padding-box;
overflow: hidden;
}
@petertwise
petertwise / acf-install-license
Last active October 2, 2025 05:54 — forked from polevaultweb/acf_pro_license_constant.php
Define the Advanced Custom Fields Pro license key with a constant
#!/bin/bash
# Setup ACF Pro to use a license key in wp-config
#
# 1. Place your license key in a file called .acf-license-key somewhere your ssh user has access to it.
# Default is in your home directory: ~/.acf-license-key
# Change the setting below if you need to put it somewhere else
# 2. install this file in /usr/local/bin or someplace in your PATH
# 3. make sure you have WP CLI installed
# 4. run acf-install-license from the root of your wordpress install
@contextmanager
def tenant(value):
"""
Context manager for tenants. Used to set and cleanup tennant.
param, value, can be Tenant object or id.
Using the context context manager
```python
with tenant(1):
Profile.objects.get(pk=1)
class TenantAwareManager(Manager):
def get_queryset(self):
tenant_id = current_tenant_id()
# If the manager was built from a queryset using
# SomeQuerySet.as_manager() or SomeManager.from_queryset(),
# we want to use that queryset instead of TenantAwareQuerySet.
if self._queryset_class != QuerySet:
return super().get_queryset().filter(tenant__id=tenant_id)
@Webreaper
Webreaper / docker-compose.yml
Last active January 30, 2026 08:41
Sample Docker-compose file which shows how to set up Sonarr, Radarr, Prowlarr, Lidarr, QBittorrent and a VPN container so that all all traffic from the containers is routed through the VPN. Also includes Plex and get_iplayer containers, which are not routed through the VPN.
# Docker compose to set up containers for all services you need:
# VPN
# Sonarr, Radarr, Lidarr, Qbittorrent
# Non-VPN
# Plex, get_iplayer
# Before running docker-compose, you should pre-create all of the following folders.
# Folders for Docker State:
# /volume1/dockerdata. - root where this docker-compose.yml should live
# /volume1/dockerdata/plex - Plex config and DB
# /volume1/dockerdata/sonarr - Sonarr config and DB
@marcus-at-localhost
marcus-at-localhost / app.scss
Last active August 17, 2021 17:00
[Standalone Bootstrap 5 Utilities for Bootstrap 4] Use the new Bootstrap 5 utilities in your Bootstrap 4 project https://v5.getbootstrap.com/docs/5.0/utilities/api/ #bootstrap #utilities
/**
* -- Overwrite Bootstrap Vars
*/
$grid-breakpoints: (
xs: 0,
sm: 576px,
@int-ua
int-ua / import_file.py
Created December 28, 2017 19:38
Import management command for django-import-export
# https://gist.github.com/bmihelac/434fceb6ba8e752f08d3
# https://github.com/django-import-export/django-import-export/issues/332
from __future__ import unicode_literals
import mimetypes
from django.core.management.base import BaseCommand, CommandError
from django.utils import termcolors
from django.utils.encoding import force_text
@anschaef
anschaef / bootstrap-4-sass-mixins-cheat-sheet.scss
Last active August 11, 2025 18:58
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.5.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/master/scss/mixins
/* -------------------------------------------------------------------------- */
/*
// ########################################################################## */
// New cheat sheet for Bootstrap 5: