This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import unicode_literals | |
import os | |
import re | |
import shutil | |
from subprocess import Popen | |
from django.contrib import localflavor | |
import polib | |
from polib import POEntry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deprecated_get_query_set(cls): | |
def get_query_set(self, *args, **kwargs): | |
self.trace.append("%s.get_query_set" % cls.__name__) | |
return cls.get_queryset(self, *args, **kwargs) | |
cls.get_query_set = get_query_set | |
# Account for already defined __getattribute__ | |
getattribute = getattr(cls, '__getattribute__') | |
def __getattribute__(self, name): | |
attribute = getattribute(self, name) | |
if name == 'get_queryset': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyManagerBase(Manager.__class__): | |
pass | |
class MyManager(Manager): | |
__metaclass__ = MyManagerBase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cls = self.__class__ | |
if klass is None: | |
klass = cls | |
elif not not issubclass(klass, cls): | |
klass = type(klass.__name__, (klass, cls), {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.dispatch.dispatcher import receiver | |
from mutant.signals import mutable_class_prepared | |
import reversion | |
@receiver(mutable_class_prepared) | |
def register_reversion(sender, existing_model_class, **kwargs): | |
reversion.register(sender) # Register the newly created model class | |
if obsolete_class: # Unregister the obsolete model class | |
reversion.unregister(existing_model_class) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import gc | |
import weakref | |
def create_reference(): | |
class A(object): | |
pass | |
class B(A): | |
parents = collections.OrderedDict([ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' | |
app_config.import_models(apps.all_models[app_config.label]) | |
apps.app_configs[app_config.label] = app_config | |
apps.clear_cache() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py | |
index b8d7c99..8c67a18 100644 | |
--- a/tests/test_client_regress/tests.py | |
+++ b/tests/test_client_regress/tests.py | |
@@ -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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |