Login

Snippets by rix

Snippet List

Manager for multiple database connections

A Django model manager capable of using different database connections. Inspired by: * [Eric Florenzano](http://www.eflorenzano.com/blog/post/easy-multi-database-support-django/) * [Kenneth Falck](http://kfalck.net/2009/07/01/multiple-databases-and-sharding-with-django) There's a more detailed version in Portuguese in my blog: [Manager para diferentes conexões de banco no Django](http://ricobl.wordpress.com/2009/08/06/manager-para-diferentes-conexoes-de-banco-no-django/)

  • multiple
  • manager
  • database
  • connection
  • databases
  • connections
Read More
Author: rix
  • 0
  • 6

Truncate string after a given number of chars keeping whole words

Truncates a string after a given length, keeping the last word complete. This filter is more precise than the default `truncatewords` filter. Words length vary too much, 10 words may result in 40 or 70 characters, so cutting by character count makes more sense. There is a [blog post](http://ricobl.wordpress.com/2008/12/23/templates-django-filtro-truncatewords-melhorado/) about this snippet (in Portuguese).

  • template
  • filter
  • templatetag
  • truncate
  • templatetags
  • words
Read More
Author: rix
  • 5
  • 6

Child aware model inheritance

Base models aren't aware of its inherited models, here is a quick solution to access child models from the base model.

  • model
  • inheritance
  • child
  • content-type
Read More
Author: rix
  • 2
  • 4

rix has posted 3 snippets.