Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
function list_contributors {
git log | grep "Author:" | sed "s/ //" | sed "s/ <.*//" | sort | uniq -c | sort
}
function total_contributors {
list_contributors | wc -l | sed 's/ *//'
}
@loic
loic / gist:6113942
Last active December 20, 2015 10:09
diff --git a/tests/admin_scripts/management/commands/color_command.py b/tests/admin_scripts/management/commands/color_command.py
new file mode 100644
index 0000000..fda93a5
--- /dev/null
+++ b/tests/admin_scripts/management/commands/color_command.py
@@ -0,0 +1,9 @@
+from django.core.management.base import NoArgsCommand
+
+
+class Command(NoArgsCommand):
@loic
loic / gist:6124159
Last active December 20, 2015 11:29
diff --git a/django/db/models/query.py b/django/db/models/query.py
index a3e0a95..84434df 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -149,10 +149,14 @@ class QuerySet(object):
"""
if not isinstance(k, (slice,) + six.integer_types):
raise TypeError
- assert ((not isinstance(k, slice) and (k >= 0))
- or (isinstance(k, slice) and (k.start is None or k.start >= 0)
@loic
loic / gist:6141793
Last active December 20, 2015 13:49
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index d09aae8..ae712e7 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1,6 +1,7 @@
import copy
import operator
from functools import partial, reduce, update_wrapper
+import warnings
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 0b941df..39700dd 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1,3 +1,4 @@
+from collections import OrderedDict
import copy
import operator
from functools import partial, reduce, update_wrapper
@@ -29,7 +30,6 @@ from django.http.response import HttpResponseBase
diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt
index 53eb8a3..c78fc4a 100644
--- a/docs/internals/deprecation.txt
+++ b/docs/internals/deprecation.txt
@@ -423,8 +423,8 @@ these changes.
* FastCGI support via the ``runfcgi`` management command will be
removed. Please deploy your project using WSGI.
-* django.utils.datastructures.SortedDict will be removed. Use the built in
- collections.OrderedDict instead.
@loic
loic / gist:6158578
Last active December 20, 2015 15:59
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
index a4cf947..17aec29 100644
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -12,7 +12,7 @@ import os
import tempfile
from django.core import validators
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, ValidationError
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index fb4cbbb..029b0ee 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -677,8 +677,9 @@ class AutoField(Field):
}
def __init__(self, *args, **kwargs):
- assert kwargs.get('primary_key', False) is True, \
- "%ss must have primary_key=True." % self.__class__.__name__
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 01ba559..6496aaa 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -185,8 +185,10 @@ class ModelBase(type):
new_class._meta.concrete_model = new_class
# Do the appropriate setup for any model parents.
- o2o_map = dict([(f.rel.to, f) for f in new_class._meta.local_fields
- if isinstance(f, OneToOneField)])
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index 7a7e615..cfee4f5 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -198,26 +198,22 @@ class JavascriptI18nTests(LiveServerTestCase):
@override_settings(LANGUAGE_CODE='de')
def test_javascript_gettext(self):
- extended_apps = list(settings.INSTALLED_APPS) + ['view_tests']
- with self.settings(INSTALLED_APPS=extended_apps):