Login

Snippets by s29

Snippet List

Alias Field

A "fake" model field which is an alias to another underlying database field. Mirrors everything including queryset lookups, instance attributes, even if the field has been used on the model already (this isn't possible just by using db_column).

Read More
Author: s29
  • 0
  • 0

Get the Django decorator/middleware cache key for given URL

This mimicks the keys used internally by the @cache_page decorators and site-wide CacheMiddleware. Now you can poke them, prod them, delete them, do what you like with them (eg, delete after you update some content and you want a specific URL refreshed).

  • cache
  • key
Read More
Author: s29
  • 2
  • 2

Error rate limiter

Prevents error flooding on high traffic production sites. Particularly useful to prevent clogging email servers etc. See [discussion](http://groups.google.com/group/django-developers/browse_thread/thread/1dabc9139dd750ca/1d86fdca23189a7d?lnk=gst&q=error#1d86fdca23189a7d) and [closed ticket](http://code.djangoproject.com/ticket/11565). Uses memcache if it can, or falls back to local, in-process memory where unavailable (down, etc). Tweak to your needs using setting ERROR_RATE_LIMIT (seconds). Requires Django 1.3+ or trunk r13981+

  • error
  • logging
  • emails
Read More
Author: s29
  • 2
  • 3

s29 has posted 3 snippets.