This file contains hidden or 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
jQuery.fn.selectOptgroup = function(options) { | |
var settings = jQuery.extend({ | |
optSelect: '_options', | |
inBetween: '', | |
optBlank: null, | |
selectBlank: null, | |
keepOrphans: true, | |
showSpeed: 200 | |
}, options); |
This file contains hidden or 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 AddOrEditView(generic.UpdateView): | |
# The following two _kwarg attributes are introduced in Django 1.4, until | |
# then, they can exist here without any concern. | |
slug_url_kwarg = 'slug' | |
pk_url_kwarg = 'pk' | |
def get_object(self, *args, **kwargs): | |
pk = self.kwargs.get(self.pk_url_kwarg) | |
slug = self.kwargs.get(self.slug_url_kwarg) | |
if pk is None and slug is None: |
This file contains hidden or 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
""" | |
To use these relative storage classes as the default, change the following | |
settings:: | |
DEFAULT_FILE_STORAGE = 'relative_storage.RelativeFileSystemStorage' | |
STATICFILES_STORAGE = 'relative_storage.RelativeStaticFilesStorage' | |
Then, you'll want to make sure that you only use the ``{% static %}`` tag when | |
referencing static files. | |
""" | |
from django.core.files import FileSystemStorage |
This file contains hidden or 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
PS1="(`basename \"$VIRTUAL_ENV\"`\$(__git_ps1 :%s))$_OLD_VIRTUAL_PS1" | |
WORKDIR=$HOME/work/`basename $VIRTUAL_ENV` | |
cd () { | |
if (( $# == 0 )); then | |
if [ -d $WORKDIR ] && [ `pwd` != $WORKDIR ]; then | |
builtin cd $WORKDIR | |
else | |
builtin cd $VIRTUAL_ENV |
This file contains hidden or 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 os | |
from django.db import models | |
from easy_thumbnails.fields import ThumbnailerImageField | |
from easy_thumbnails.files import Thumbnailer, ThumbnailerImageFieldFile | |
import uuid | |
def _get_file_path(instance, filename): | |
filename = str(uuid.uuid4()) + os.splitext(filename) | |
return '/'.join('photo', filename) |
This file contains hidden or 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 run_validators(self, value): | |
if value in validators.EMPTY_VALUES: | |
return | |
errors = [] | |
for v in self.validators: | |
try: | |
v(value) | |
except ValidationError, e: | |
message = None | |
if hasattr(e, 'code'): |
This file contains hidden or 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
# Use 4 spaces, not tabs :P | |
# Don't go overboard with your newlines. | |
from django.shortcuts import render, redirect | |
from django.core.urlresolvers import reverse | |
# Do global imports rather than local ones unless you're specifically avoiding | |
# a circular import. | |
# Personally, I prefer to import the module rather than the classes. |
This file contains hidden or 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
filters = Q() | |
for value in your_list: | |
filters |= Q(your_field=value) | |
qs = qs.filter(filters) |
This file contains hidden or 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/template/base.py b/django/template/base.py | |
index ab44bfb..3567756 100644 | |
--- a/django/template/base.py | |
+++ b/django/template/base.py | |
@@ -551,9 +551,9 @@ class FilterExpression(object): | |
args = [] | |
constant_arg, var_arg = match.group("constant_arg", "var_arg") | |
if constant_arg: | |
- args.append((False, Variable(constant_arg).resolve({}))) | |
+ args.append(mark_safe(Variable(constant_arg).resolve({}))) |
This file contains hidden or 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 sublime, sublime_plugin | |
import string | |
import textwrap | |
import re | |
import comment | |
def previous_line(view, sr): | |
"""sr should be a Region covering the entire hard line""" | |
if sr.begin() == 0: | |
return None |