djangosnippets.org: Latest snippets posted by robharveyhttps://djangosnippets.org/users/robharvey/2008-03-02T03:34:31.882759-06:00robharveyfiltered ModelChoiceField queries
2008-03-02T03:34:31.882759-06:00robharveyhttps://djangosnippets.org/snippets/625/<p>ModelChoiceField allows you to use filtered queries to simplify your forms. This is great for adding objects but can fall down when you edit an existing object and the original query no longer contains the referenced field (e.g. I like to use an "active" field in several objects).
</p>
<p>The fix …</p>
Freely redistributablecustom sql without table names
2007-05-18T19:23:02.170112-05:00robharveyhttps://djangosnippets.org/snippets/242/<p>Keeps database table names out of custom SQL code, but still allows for correct parameter passing in the execute function. (psycopg doesn't substitute table or field names, only data, in the execute function)</p>
Freely redistributablecustom css classes for newforms
2007-05-14T16:16:53.211091-05:00robharveyhttps://djangosnippets.org/snippets/235/<p>This isn't really any trick, its just that I didn't find any documentation of this or any references in searching. There are a few changes proposed for css classes which might make this redundant, but for now this works!</p>
<p>If you want to add attributes for any fields, just include …</p>
Freely redistributableMore admin clock time increments
2007-04-17T17:53:47.197563-05:00robharveyhttps://djangosnippets.org/snippets/187/<p>This is quite a hack (need to modify Django code), but relatively simple and stable. It displays various times in whichever increments and columns you specify, rather than just Midnight, Noon, Now & 6am. You can use it throughout your admin and newforms-admin code.</p>
<p>This is a (slightly updated) copy …</p>
Freely redistributableSimple admin list thumbnail view
2007-04-08T12:52:50.228894-05:00robharveyhttps://djangosnippets.org/snippets/162/<p>This is a very simple way to display images within the admin list view. It is not efficient in the sense that the images are being downloaded in original format, however for cases where the images are not regularly accessed it may be a straightforward option.
Can also be tied …</p>
Freely redistributable