Skip to content

Instantly share code, notes, and snippets.

View peterfarrell's full-sized avatar
🏠
Working from home

PJ Farrell peterfarrell

🏠
Working from home
View GitHub Profile
@loilo
loilo / pass-slots.md
Last active February 20, 2025 09:47
Vue: Pass Slots through from Parent to Child Components

Vue: Pass Slots through from Parent to Child Components

The Situation

  • We've got some components A, B and C which provide different slots.
    const A = {
      template: `<div><slot name="a">Default A Content</slot></div>`
    }

const B = {

@alysivji
alysivji / graph_transitions.py
Created March 30, 2021 06:05
Exporting Mermaid Markdown for django-fsm
# -*- coding: utf-8; mode: django -*-
import graphviz
from optparse import make_option
from django.core.management.base import BaseCommand
from django.utils.encoding import force_text
from django_fsm import FSMFieldMixin, GET_STATE, RETURN_VALUE
try:
@russmatney
russmatney / django_filter_grouping_impl.py
Created November 30, 2021 21:36
Django-filters group nested queries impl
class GroupFilter:
"""
The work here is largely cherry-picked from this unmerged django-filters PR:
https://github.com/carltongibson/django-filter/pull/1167/files
"""
def __init__(self, filter_names):
self.filter_names = filter_names
def set_parent(self, parent):
@sameerkumar18
sameerkumar18 / yourapp_admin.py
Last active October 7, 2024 18:21
Django Admin: Celery Retry Task by ID
# Add this code in any Django app's admin.py
# Works for all Task Statuses; you can filter them in line 12.
import ast
import importlib
import json
from django.contrib import admin
from django.contrib import messages
from django.utils.safestring import mark_safe
@yuekui
yuekui / group_filter_set.py
Created March 2, 2022 21:54
GroupFilterSet to reduce inner joins for performance.
from django.db.models import Q
from django.db.models.constants import LOOKUP_SEP
from django_filters import rest_framework as django_filters
from django_filters.constants import EMPTY_VALUES
class GroupFilterSet(django_filters.FilterSet):
def filter_queryset(self, queryset):
"""
Group the fitlers by the first join table to