djangosnippets.org: Latest snippets posted by zerokhttps://djangosnippets.org/users/zerok/2008-08-15T14:50:34.506282-05:00zerokManager method for limiting GenericForeignKey queries
2008-08-15T14:50:34.506282-05:00zerokhttps://djangosnippets.org/snippets/984/<p>This is a simple manager that offers one additional method called <code>relate</code>, which fetches generic foreign keys (as referenced by <code>content_type</code> and <code>object_id</code> fields) without requiring one additional query for each contained element. </p>
<p>Basically, when working with generic foreign keys (and esp. in the usecase of having something like …</p>
Freely redistributableI18n URLs via Middleware
2007-08-17T03:47:33.708290-05:00zerokhttps://djangosnippets.org/snippets/371/<p>This is an example middleware that is highly inspired by how Symfony handles <a href="http://www.symfony-project.com/book/trunk/13-I18n-and-L10n#Changing the Culture for a User">i18n in URLs</a>. You basically set a (?P<dj_culture>[\w-]+) pattern in your URL and this middleware will determine the language to use for the i18n toolkit for Django. </p>
<p>It also removes the dj_culture parameter after dealing with …</p>
Freely redistributable