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
$(function() { | |
if (!('placeholder' in document.createElement('input'))) { | |
$('input[placeholder], textarea[placeholder]').each(function() { | |
var text = this.getAttribute('placeholder'); | |
var fld = $(this); | |
function setPlaceholder() { | |
if (fld.val() == text || fld.val() == '') { | |
fld.addClass('jqPlaceholder'); | |
fld.val(text); |
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 AbstractMixin(object): | |
_classcache = {} | |
@classmethod | |
def contribute(cls): | |
return {} | |
@classmethod | |
def construct(cls, *args, **kwargs): | |
attrs = cls.contribute(*args, **kwargs) |
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
{% load liczba_mnoga %} | |
<p>{% liczba_mnoga user_count "jedna osoba" "%(n)s osoby" "%(n)s osób" %}</p> |
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
{% load i18n %} | |
{% if u.sex == 'm' %} | |
{% blocktrans with u.get_full_name as male %} | |
{{ male }} set up us a bomb. | |
{% endblocktrans %} | |
{% else %} | |
{% blocktrans with u.get_full_name as female %} | |
{{ female }} set up us a bomb. | |
{% endblocktrans %} |
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 Barney(object): | |
def __enter__(self): | |
print 'legen...' | |
def __exit__(self, exc_type, exc_value, traceback): | |
print '...dary' | |
with Barney(): | |
print 'wait for it' |
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
""" | |
sqlite3 database backend with non-synchronous mode. | |
It gives you a huge performance boost by turning off the overzealous | |
synchronous operation mode. The tradeoff is less data protection in case of | |
power outages but come on, you were not going to use it in production, were you? | |
""" | |
from django.db.backends.sqlite3.base import ( | |
DatabaseWrapper as Sqlite3Wrapper, | |
DatabaseError, |
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 import forms | |
from satchless.forms.widgets import DecimalInput | |
from satchless.product.forms import BaseVariantForm | |
from . import models | |
class ProductPriceForm(forms.ModelForm): | |
class Meta: | |
widgets = { | |
'price': DecimalInput(min_decimal_places=2), |
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 glob | |
import os | |
from xml.etree import ElementTree | |
TEMP = './tmp.svg' | |
def rebrand(fname, brand): | |
svg = ElementTree.parse(fname) | |
for e in svg.iterfind(".//{http://www.w3.org/2000/svg}rect[@id='background']"): | |
e.set('style', 'fill:url(#%s);' % (brand,)) |
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 query_db(ids): | |
print('Querying the database:', ids) | |
# fake some data | |
results = [] | |
for id_ in ids: | |
results.extend(range(id_ + 2, id_ + 5)) | |
# simulate DISTINCT() | |
return set(results) | |
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/django/db/models/expressions.py b/django/db/models/expressions.py | |
index 4306193..bf965c1 100644 | |
--- a/django/db/models/expressions.py | |
+++ b/django/db/models/expressions.py | |
@@ -340,11 +340,27 @@ def reverse_ordering(self): | |
return self | |
+class ExpressionFilter(object): | |
+ def __init__(self, expression, value, lookup): |
OlderNewer