Skip to content

Instantly share code, notes, and snippets.

<!doctype html>
<html>
<head>
</head>
<body>
<input name="field" type="text" required/>
</body>
<html>
var input = Sizzle('[required]')[0]; //input#field
Sizzle.matches('[required]', [input]); // [ ]
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Django Docs Search</ShortName>
<Description>Search in Django Documents</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAapJREFUOI2lk09I02EYxz/P+/78uSxQUnfISsibHjqI4C7u0KZCkwoFMVL0kOAlPIlg4CEI8aztqB4UCqQYbY4IPBRLLwV1NAJJFPOghenU358Oc6MfmxPqe3rg/T6f9/nDI+Mzk+7rD2/4F0UCrUjjYMgtZlKiAHBcp/B7sWTTKGE1mmTl2RJaaVJTcVaml/CZvpzHKAYQERBBsmbDyFV0LqDiUjla6UyyZBDBR3cRIH2cLgxQSjHQ3kNXsIPqiso8aGJiAVFC+0g36eOjfMCDUBdDd/qxbItX7xLs7v+kr60brTJlX7xQhlJFWogEWgGYSz4nGpsF4H6oE63M06FknbnAu4Wq8ssAfNtazx/KGfIAtnd3AAg0NOUZRcTzc1aeFl4sxxjrHSYSCHOzrp69/V+YRgkAPrMUdboN27ELA16+j2M7Nj237nHjSi3X/DUcHqX5/mOT6/6rAPw+PODEOikMAIilksRSSUQErTSWbaFEePrwMQCfvn45u4W/5boulm2hlebJwCihxhYc12H+7aJ3NucdE2Ru4nZzmPXtDT6uffYC/vec/wDjbXl0qXpOzgAAAABJRU5ErkJggg==</Image>
<Url type="text/html"
@charettes
charettes / authuser.md
Created April 3, 2012 17:46 — forked from jacobian/authuser.md
Upgrading auth.User - the profile approach

Upgrading auth.User - the profile approach

This proposal presents a "middle ground" approach to improving and refactoring auth.User, based around a new concept of "profiles". These profiles provide the main customization hook for the user model, but the user model itself stays concrete and cannot be replaced.

I call it a middle ground because it doesn't go as far as refactoring the whole auth app -- a laudable goal, but one that I believe will ultimately take far too long -- but goes a bit further than just fixing the most egregious errors (username length, for example).

This proposal includes a fair number of design decisions -- you're reading the fifth or sixth draft. To keep things clear, the options have been pruned out and on the one I think is the "winner" is still there. But see the FAQ at the end for some discussion and justification of various choices.

The User model

@charettes
charettes / django-github-pull-ticket-linkify.js
Last active October 3, 2015 21:28
Linkify ticket numbers in django github pull request
// ==UserScript==
// @name Django github ticket number linkify
// @namespace django-github-ticket-linkify
// @description Linkify ticket numbers to django's track on github
// @grant none
// @include https://github.com/*/django/*
// ==/UserScript==
const TICKET_NUMBER_LINKIFY = ' <a target="_new" href="https://code.djangoproject.com/ticket/$1">#$1</a>';
@charettes
charettes / generate.py
Created December 20, 2012 20:31
Django ticket #19482 localflavor apps locales
#!/usr/bin/env python
from __future__ import unicode_literals
import os
import re
import shutil
from subprocess import Popen
from django.contrib import localflavor
import polib
from polib import POEntry
@charettes
charettes / qs.py
Created February 5, 2013 21:35
Django #15363
def deprecated_get_query_set(cls):
def get_query_set(self, *args, **kwargs):
self.trace.append("%s.get_query_set" % cls.__name__)
return cls.get_queryset(self, *args, **kwargs)
cls.get_query_set = get_query_set
# Account for already defined __getattribute__
getattribute = getattr(cls, '__getattribute__')
def __getattribute__(self, name):
attribute = getattribute(self, name)
if name == 'get_queryset':
class MyManagerBase(Manager.__class__):
pass
class MyManager(Manager):
__metaclass__ = MyManagerBase
@charettes
charettes / django-mutant-usecase.rst
Last active March 26, 2019 09:33
django-mutant use case.

Django mutant use cases

Model creation

Reproducing an existing model setup

from __future__ import unicode_literals
from django.db import models
class QuerySetClassManager(models.Manager):
"""
A mixin that refers to it's queryset_class attribute to create it.
"""
queryset_class = models.query.QuerySet