Skip to content

Instantly share code, notes, and snippets.

@loic
loic / -
Created November 9, 2013 06:23
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 6299b20..577f503 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -268,7 +268,7 @@ class ReverseSingleRelatedObjectDescriptor(six.with_metaclass(RenameRelatedObjec
rel_obj_attr = self.field.get_foreign_related_value
instance_attr = self.field.get_local_related_value
instances_dict = dict((instance_attr(inst), inst) for inst in instances)
- query = {'%s__in' % self.field.related_query_name(): instances}
+ query = {'%s__in' % self.field.related_field.name: [rel_obj_attr(i)[0] for i in instances]}
var localNow = new Date();
localNow.setTime(localNow.getTime() + 1);
console.log(localNow);
// Sat Nov 02 2013 16:09:29 GMT-0500 (CDT)
var localNow = new Date();
localNow.setTime(localNow.getTime() + 1000 * 60 * 60 * 13);
console.log(localNow);
// Sun Nov 03 2013 04:12:22 GMT-0600 (CST)
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 34e8dab..55b9ab3 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1620,9 +1620,10 @@ class RawQuerySet(object):
class Prefetch(object):
- def __init__(self, lookup, queryset=None):
+ def __init__(self, lookup, queryset=None, parent_filter=None):
@loic
loic / tests.py
Last active December 26, 2015 18:59
# $ PYTHONPATH=.. ./manage.py test
# Creating test database for alias 'default'...
# test_list_backed_lookup
# 3.81117606163
# .test_manager_backed_lookup
# 6.57371211052
# .
# ----------------------------------------------------------------------
# Ran 2 tests in 12.099s
_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 *
@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
var item = UIActivity.FromObject ("hello");
var activityItems = new NSObject[] { item };
UIActivity[] applicationActivities = null;
var activityController = new UIActivityViewController (activityItems, applicationActivities);
PresentViewController (activityController, true, null);
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) {
# 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,
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):