Skip to content

Instantly share code, notes, and snippets.

View pratyushmittal's full-sized avatar

Pratyush Mittal pratyushmittal

View GitHub Profile
pratyushmittal /
Last active June 24, 2023 09:31
An experimental `get_change_list` function to create a `ChangeList` object from any queryset. Shared it here:
from django.contrib.admin import ModelAdmin
from django.contrib.admin.sites import AdminSite
class DummyChangeListAdmin:
def get_queryset(self, *args, **kwargs):
return self._queryset
def has_change_permission(self, *args, **kwargs):
return False
pratyushmittal /
Last active November 15, 2022 09:12
Using Django ChangeList in custom views

Using Django's changelist feature in custom views

Django has a fabulous ChangeList feature. It is used to show lists in admin. It also provides:

  1. Search bar
  2. Date Hierarchy filters
  3. Other filters in sidebar (including option to define custom filters)
  4. Handles pagination
pratyushmittal / .env
Last active September 7, 2022 07:04
A SwiftBar script to show unread emails in menu-bar
pratyushmittal / justfile
Created July 31, 2022 13:43
I like to manually mark each line as checked during code reviews. This script allows that. Blog post about it:
just --list
#!/usr/bin/env bash
cd {{invocation_directory()}}
source_branch_name=$(git branch --show-current)
git merge main
pratyushmittal / block.js
Created June 25, 2015 07:00
AngularJS - Adding content outside ng-view
function block($document) {
function blockLink(scope, elem, attrs) {
var element = elem[0];
var targetTag = 'block-' +;
var blockElem = angular.element($document).find(targetTag)[0];
blockElem.innerHTML = '';
scope.$on('$destroy', function() {