Login

Snippets by ericflo

Snippet List

Print Exceptions to the Console

Put this in an __init__.py somewhere that will be executed on initialization and all errors will be printed out to stderr. Useful for debugging Facebook apps, javascript calls, etc.

  • print
  • console
  • exception
  • signal
Read More

Case Insensitive Authentication Backend

By enabling this backend: AUTHENTICATION_BACKENDS = ( 'path.to.my.backends.CaseInsensitiveModelBackend', ) Your users will now be able to log in with their username, no matter whether the letters are upper- or lower-case.

  • auth
  • case
  • case-insensitive
  • backend
  • insensitive
Read More

Update All Apps to Latest Revision

A simple script that I have put in my Django applications directory to fetch the latest application code from git and svn. For example, your directory structure might look like so: django-apps/ django-tagging/ django-pagination/ django-registration/ django-threadedcomments/ django-mptt/ update_apps.py Where update_apps.py is the source of this snippet. To run, simply execute: # python update_apps.py And the script will iterate through all of your apps and update them to the latest version.

  • script
  • update
  • apps
  • project
  • svn
  • git
Read More

SQL Printing Middleware

Just put it in your python path and add it into MIDDLEWARE_CLASSES. I know that there are a couple of snippets on this site that do something similar to this, but none of them quite suited me. I wanted something that would indent and space the SQL so that I could differentiate it from the other output from the development server. Also, I wanted something that would output total query execution time, which my solution does. I just hope that it's useful for someone else, too! UPDATE: Now this should no longer get upset when running it on windows.

  • sql
  • middleware
  • profile
  • debug
  • help
  • console
  • printing
  • speed
Read More

Pygments Rendering Template Filter

Finds all ``<code></code>`` blocks in a text block and replaces it with pygments-highlighted html semantics. It tries to guess the format of the input, and it falls back to Python highlighting if it can't decide. This is useful for highlighting code snippets on a blog, for instance.

  • template
  • filter
  • pygments
  • highlighting
  • code
Read More

ericflo has posted 5 snippets.