Skip to content

Instantly share code, notes, and snippets.

goutham2027 /
Last active Jul 12, 2016
using django reversion
pip install django-reversion

Add reversion to INSTALLED_APPS

from itertools import chain
from operator import attrgetter
# ascending oreder
result_list = sorted(
chain(queryset1, queryset2),
# descending order
mattmcc /
Created Mar 27, 2013
Quick & dirty "read-only" model for using SQL views
class ViewManager(models.Manager):
def bulk_create(self, *args, **kwargs):
raise NotImplementedError
def create(self, *args, **kwargs):
raise NotImplementedError
def get_or_create(self, *args, **kwargs):
raise NotImplementedError
rturowicz /
Last active Dec 19, 2018
django - intermediate admin page
# admin action definition
def make_copy(self, request, queryset):
form = None
if 'apply' in request.POST:
form = CopyPageForm(request.POST)
if form.is_valid():
issue = form.cleaned_data['issue']
bunkat / index.html
Created Apr 8, 2012
Timeline using d3.js
View index.html
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Chronological Diagram of Asia</title>
<script type="text/javascript" src=""></script>
<style type="text/css">
.chart {
shape-rendering: crispEdges;
josharian /
Created Dec 9, 2011
Simple Django middleware that delays the processing of each request
This module provides very simple Django middleware that sleeps on every request.
This is useful when you want to simulate slow response times (as might be
encountered, say, on a cell network).
To use, add this middleware, and add a value for SLEEP_TIME to your settings.
Possible future feature: Look for an X-Django-Sleep header on each request,
to let the client specify per-request sleep time.
View Textos a profundidad.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
gonzalo-bulnes / comunas.json
Last active Apr 30, 2020
Comunas de Chile (seed Ruby on Rails, JSON) - (see also
View comunas.json
"name": "Arica",
"code": "15101",
"provincia": "Arica",
"region": "Arica y Parinacota",
"region_number": "XV",
"region_iso_3166_2": "CL-AP"
MrYoda /
Last active Aug 10, 2020
Python 3, Django 1.9+: Excel file creation and send on-the-fly with XlsxWriter & BytesIO
import xlsxwriter
from io import BytesIO
from django.http import StreamingHttpResponse
from django.views.generic import View
def get_foo_table_data():
Some table data
mdesantis /
Last active Aug 17, 2020 — forked from delameko/
Upgrading PostgreSQL from 9.6 to 10 on Ubuntu 16.04


Install Postgres 10, and then:

sudo pg_dropcluster 10 main --stop
sudo pg_upgradecluster 9.6 main
sudo pg_dropcluster 9.6 main