djangosnippets.org: Latest snippets posted by mattdwhttp://djangosnippets.org/users/mattdw/2008-10-01T17:10:18.657351-05:00mattdwChain multiple querysets into one
2008-10-01T17:10:18.657351-05:00mattdwhttp://djangosnippets.org/snippets/1103/<p>This class acts as a wrapper around multiple querysets. Use it if you want to chain multiple QSs together without combining them with | or &. eg., to put title matches ahead of body matches:</p>
<pre><code>>>> qs1 = Event.objects.filter(## title matches ##)
>>> qs2 = Event.objects.filter(## matches in other fields …</code></pre>
Freely redistributableEasy file upload handler
2008-09-07T22:34:36.404752-05:00mattdwhttp://djangosnippets.org/snippets/1036/<p>This function emulates the file upload behaviour of django's admin, but can be used in any view. It takes a list of POST keys that represent uploaded files, and saves the files into a date-formatted directory in the same manner as a <code>FileField</code>'s <code>upload_to</code> argument.</p>
Freely redistributableOverriding Third-party Admin
2008-09-07T22:18:16.063131-05:00mattdwhttp://djangosnippets.org/snippets/1035/<p>With the advent of newforms-admin it's now possible to override admin interfaces without having to change any code in third-party modules. This example shows how to enable a rich-text editor for <code>django.contrib.flatpages</code> without touching Django's code at all. (Actual embedding of the editor via Javascript left as an exercise for …</p>
Freely redistributable