djangosnippets.org: Latest snippets posted by hawkeyehttps://djangosnippets.org/users/hawkeye/2008-02-22T20:30:32.264523-06:00hawkeyeUserForeignKey
2008-02-22T20:30:32.264523-06:00hawkeyehttps://djangosnippets.org/snippets/612/<p>Many models are tightly coupled to the default Django <code>User</code> model (<code>django.contrib.auth.models.User</code>).</p>
<p>Sometimes this user model just doesn't fit everyone's needs. By using <code>UserForeignKey</code> it is possible to make the <code>User</code> model configurable, encouraging loose coupling.</p>
<p>Additionally, this can help to prevent circular imports between <code>User</code> and another …</p>
Freely redistributableseveral_random template filter
2007-05-11T17:35:11.906138-05:00hawkeyehttps://djangosnippets.org/snippets/230/<p>Allows the selection of one or more items from a list.</p>
<p>The built-int <code>random</code> filter only allows you to select a single at a time, and repeated use can return the same item many times.</p>
<p><strong>Example:</strong></p>
<p><code>{% for random_item in item_list|several_random:3 %} ... {% endfor%}</code></p>
<p><strong>Note:</strong> If you're running this …</p>
Freely redistributableHttpMethodsMiddleware
2007-04-12T11:58:26.797453-05:00hawkeyehttps://djangosnippets.org/snippets/174/<p>This middleware allows developers to "fake" browser support for HTTP methods. Even though most modern browsers only support GET and POST, the HTTP standard defines others. In the context of REST, PUT and DELETE are used for client interaction with the server.</p>
<p>For forms with a PUT or DELETE method, …</p>
Freely redistributable