Skip to content

Instantly share code, notes, and snippets.

charettes /
Created Feb 12, 2020
Allow module aliasing
from __future__ import unicode_literals
import re
import sys
from importlib import import_module
class _AliasLoader(object):
def __init__(self, alias, aliased):
self.alias = alias
charettes /
Created Mar 28, 2019
class ImportForeignModel(Operation):
"""Import a model from a foreign app to this one."""
def __init__(self, app_label, model_name):
self.app_label = app_label
self.model_name = model_name.lower()
def state_forwards(self, app_label, state):
imported_model_state = state.models[self.app_label, self.model_name].clone()
# Change the app label.
#!/usr/bin/env python
This script assumes you have both flake8 and flake8-commas packages
installed in the Python environment you use to run this script.
import subprocess
import sys
from collections import defaultdict
diff --git a/tests/test_client_regress/ b/tests/test_client_regress/
index b8d7c99..8c67a18 100644
--- a/tests/test_client_regress/
+++ b/tests/test_client_regress/
@@ -467,6 +467,10 @@ class AssertRedirectsTests(SimpleTestCase):
self.assertEqual(response.request.get('wsgi.url_scheme'), 'https')
self.assertEqual(response.request.get('SERVER_NAME'), 'otherserver')
self.assertEqual(response.request.get('SERVER_PORT'), '8443')
+ response = self.client.get('/redirect_other_host/', follow=False)
+ self.assertRedirects(
# Add the common tests module as an application to allow its models
# table to be created even if they are not part of the common migations.
app_config = AppConfig.create(__package__)
app_config.label = 'common_tests'
apps.app_configs[app_config.label] = app_config
from django.db import router
from django.db.models import deletion
def ALLOW_MIGRATE_CASCADE(collector, field, sub_objs, using):
opts = sub_objs[0]._meta
if router.allow_migrate(using, opts.app_label, opts.model_name):
deletion.CASCADE(collector, field, sub_objs, using)
charettes /
Created Dec 23, 2015
Python 3.5 OrderedDict bug
import collections
import gc
import weakref
def create_reference():
class A(object):
class B(A):
parents = collections.OrderedDict([
View detect.patch
diff --git a/django/test/ b/django/test/
index 1106c52..e053bd3 100644
--- a/django/test/
+++ b/django/test/
@@ -211,6 +211,27 @@ class DiscoverRunner(object):
result = self.run_suite(suite)
+ from itertools import groupby
+ def keyfunc(test):
View gist:abdad035dda9574f11d6
(django-sundial)simon@simon-laptop:~/workspace/django-sundial$ python bdist_wheel --universal
running bdist_wheel
running build
installing to build/bdist.linux-x86_64/wheel
running install
running install_egg_info
running egg_info
creating django_sundial.egg-info
writing requirements to django_sundial.egg-info/requires.txt
writing django_sundial.egg-info/PKG-INFO

Keybase proof

I hereby claim:

  • I am charettes on github.
  • I am charettes ( on keybase.
  • I have a public key whose fingerprint is 8557 62CE 0C47 C935 9480 44AA 72AF 89A0 B1B4 EDB3

To claim this, I am signing this object: