Skip to content

Instantly share code, notes, and snippets.

#################################
#
# Backend
#
#################################
# Backend to use: "xrender" or "glx".
# GLX backend is typically much faster but depends on a sane driver.
backend = "glx";
@FeroxTL
FeroxTL / SQLPrintingMiddleware.py
Last active August 6, 2017 18:59 — forked from vstoykov/SQLPrintingMiddleware.py
Django Middleware to print sql queries in debug console
"""
Originaly code was taken from http://djangosnippets.org/snippets/290/
But I was made some improvements like:
- print URL from what queries was
- don't show queries from static URLs (MEDIA_URL and STATIC_URL, also for /favicon.ico).
- If DEBUG is False tell to django to not use this middleware
- Remove guessing of terminal width (This breaks the rendered SQL)
"""
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
#!/usr/bin/env python
import re
import sys
import subprocess
from collections import defaultdict
MIGRATION_REGEX = r'.+\/(?P<app>.+)\/migrations\/(?P<num>\d{4})_.+.py'
fn, previous_head, current_head, is_branch = sys.argv
if not is_branch == '1' or previous_head == current_head:
# __init__.py
default_app_config = 'apps.gallery.app.Config'
# app.py
from django.apps import AppConfig
class Config(AppConfig):
@FeroxTL
FeroxTL / my_comments.py
Created October 18, 2015 16:26
django contrib comments template tag for showing comments with pagination
# -*- coding: utf-8 -*-
import six
from django import template
from django.template.loader import render_to_string
from django.conf import settings
from django.utils.encoding import smart_text
from django.contrib.contenttypes.models import ContentType
import django_comments
@FeroxTL
FeroxTL / MultipleFormsCBV.py
Last active September 20, 2015 15:45
django CBV mutliple forms mixin
class MultipleFormxMixin(object):
form_classes = []
initials = {}
prefixes = {}
form_names = []
def get_forms(self, names=None):
names = names or self.form_names
if len(names) != len(self.form_classes):