Skip to content

Instantly share code, notes, and snippets.

@loic
loic / patch.diff
Last active December 20, 2015 23:19
$ python3 ./tests/runtests.py model_inheritance_regress
Creating test database for alias 'default'...
Creating test database for alias 'other'...
E.....x.F............
======================================================================
ERROR: test_abstract_base_class_m2m_relation_inheritance (model_inheritance_regress.tests.ModelInheritanceTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/loic/Dev/django/tests/model_inheritance_regress/tests.py", line 386, in test_abstract_base_class_m2m_relation_inheritance
messy_parent = messy.bachelorparty_ptr
#!/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 / -
Created August 21, 2013 07:13
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 836d394..3b60aa6 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -48,6 +48,12 @@ class QuerySet(object):
"""
def __init__(self, model=None, query=None, using=None):
+ if hasattr(model, 'all'):
+ queryset = model.all()
diff --git a/tests/template_tests/templates/recursive_include.html b/tests/template_tests/templates/recursive_include.html
new file mode 100644
index 0000000..fdc7702
--- /dev/null
+++ b/tests/template_tests/templates/recursive_include.html
@@ -0,0 +1,7 @@
+"Recursion!"
+{% for comment in comments %}
+ {{ comment.comment }}
+ {% if comment.children %}
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index d7908ac..4ba95ec 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -121,55 +121,34 @@ class ExtendsNode(Node):
# the same.
return compiled_parent._render(context)
-class BaseIncludeNode(Node):
- def __init__(self, *args, **kwargs):
# Django doesn't fire signals for parent Models.
# https://code.djangoproject.com/ticket/9318
def _save_table(self, raw=False, cls=None, force_insert=False,
force_update=False, using=None, update_fields=None):
if cls is not self.__class__:
signals.pre_save.send(sender=cls, instance=self,
raw=raw, using=using, update_fields=update_fields)
updated = super(Node, self)._save_table(raw, cls, force_insert,
var imagePicker = new UIImagePickerController();
var actionSheet = new UIActionSheet (null, null, "Cancel", null, new string[] {"Take photo", "Choose Existing"});
actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) {
if (b.ButtonIndex == 0) {
imagePicker.SourceType = UIImagePickerControllerSourceType.Camera;
} else if (b.ButtonIndex == 1) {
imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
}
if (b.ButtonIndex != actionSheet.CancelButtonIndex) {
var item = UIActivity.FromObject ("hello");
var activityItems = new NSObject[] { item };
UIActivity[] applicationActivities = null;
var activityController = new UIActivityViewController (activityItems, applicationActivities);
PresentViewController (activityController, true, null);
@classmethod
def prefetch_related(cls, instances):
pass
@classmethod
def prefetcher(cls, instances, queryset, fk_attr):
cache = {}
for instance in instances:
cache[getattr(instance, fk_attr + '_id')] = instance
_detail_new.py
_detail_old.py
detail.py
if settings.NEW_GCBV:
from _detail_new import *
else:
PendingDeprecationWarning # Django 1.7
DeprecationWarning # Django 1.8
from _detail_old import *