Skip to content

Instantly share code, notes, and snippets.

View pratyushmittal's full-sized avatar

Pratyush Mittal pratyushmittal

View GitHub Profile
@pratyushmittal
pratyushmittal / change_list.py
Last active June 24, 2023 09:31
An experimental `get_change_list` function to create a `ChangeList` object from any queryset. Shared it here: https://forum.djangoproject.com/t/using-changelist-in-views/21825
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
pratyushmittal / README.md
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
pratyushmittal / .env
Last active September 7, 2022 07:04
A SwiftBar script to show unread emails in menu-bar
[email protected]
PASSWORD=your-app-password
@pratyushmittal
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: https://fully-faltoo.com/p/reviewing-each-line-of-code/
default:
just --list
review:
#!/usr/bin/env bash
cd {{invocation_directory()}}
source_branch_name=$(git branch --show-current)
review_branch_name=review-${source_branch_name}
git merge main
@pratyushmittal
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];
element.removeAttribute('block');
element.removeAttribute('target');
var targetTag = 'block-' + attrs.target;
var blockElem = angular.element($document).find(targetTag)[0];
blockElem.innerHTML = '';
blockElem.appendChild(element);
scope.$on('$destroy', function() {
*.pyc
*.jpe
*.png