Skip to content

Instantly share code, notes, and snippets.

View fiee's full-sized avatar

Henning Hraban Ramm fiee

View GitHub Profile
class QuerySetDoubleIteration(Exception):
"A QuerySet was iterated over twice, you probably want to list() it."
pass
# "Skinny" here means we use iterator by default, rather than
# ballooning in memory.
class SkinnyManager(Manager):
def get_query_set(self):
return SkinnyQuerySet(self.model, using=self._db)
diff --git a/django_root/django/db/models/base.py b/django_root/django/db/models/base.py
index 37331b3..4da2802 100644
--- a/django_root/django/db/models/base.py
+++ b/django_root/django/db/models/base.py
@@ -5,6 +5,7 @@ from itertools import izip
import django.db.models.manager # Imported to register signal handler.
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS
from django.core import validators
+from django.db.models.expressions import ExpressionNode
from django.db.models.fields import AutoField, FieldDoesNotExist
def queryset_to_dict(qs, key='pk'):
"""
Given a queryset will transform it into a dictionary based on ``key``.
"""
return dict((getattr(u, key), u) for u in qs)
def distinct(l):
"""
Given an iterable will return a list of all distinct values.
"""
from django import template
import re
register = template.Library()
class_matcher = re.compile('(class="[^"]+)(")')
tag_matcher = re.compile(r'<([a-z0-9]+)([ >])')
def mark_current(navigation, current):
current_tokens = current.split('/')