Login

Snippets by sgb

Snippet List

SMTPConnection with Return-Path

Sometimes when sending email you want to specify a Return-Path different from the "From:" address on the email. The Return-Path is used for bounced email and is required for [VERP](http://en.wikipedia.org/wiki/VERP). This class overrides SMTPConnection so that you can specify return_path.

  • email
Read More
Author: sgb
  • 2
  • 3

Profiling middleware using cProfile

Similar to [Profiling Middleware](http://www.djangosnippets.org/snippets/186/), but uses cProfile instead of hotshot. Append ?prof to the URL to see profiling output instead of page output.

  • middleware
  • performance
  • profiler
Read More
Author: sgb
  • 5
  • 24

Time ranges like 7-9 p.m.

Template filter to format a start and end time in to a range. Uses Django's ["P" format](http://www.djangoproject.com/documentation/templates/#now) and assumes start and end time are on the same day or night before/morning after. `{{ start_time|time_range:end_time }}` Examples: 7-8 p.m. 8 p.m. - midnight noon - 4 p.m. 9:45 a.m. - 5:15 p.m. 10:30 p.m. - 1:30 a.m.

  • format
  • time
  • range
Read More
Author: sgb
  • 3
  • 4

sgb has posted 3 snippets.