djangosnippets.org: Latest snippets posted by baumer1122https://djangosnippets.org/users/baumer1122/2008-07-31T12:28:58.860068-05:00baumer1122Admin Image Widget
2008-07-31T12:28:58.860068-05:00baumer1122https://djangosnippets.org/snippets/934/<p>A FileField Widget that displays an image instead of a file path if the current file is an image. Could also be used with sorl.thumbnail to generate thumbnail images.</p>
<p><strong>Example</strong></p>
<pre><code>class FileUploadForm(forms.ModelForm):
upload = forms.FileField(widget=AdminThumbnailWidget)
class Meta:
model = FileUpload
class FileUploadAdmin(admin.ModelAdmin):
form = FileUploadForm
admin.site.register(FileUpload, FileUploadAdmin)
</code></pre>
Freely redistributableCreator/updater fields for admin
2008-07-21T22:16:13.297221-05:00baumer1122https://djangosnippets.org/snippets/903/<p>This ModelAdmin class sets fields for models saved in admin corresponding to the user that created the object and the user that last updated the object. Trivial for the current model, but a little more involved to make it work with inlines.</p>
<p>The fields still show up as drop-downs ( …</p>
Freely redistributableSearch Docs with Shortwave
2008-07-08T11:00:03.698681-05:00baumer1122https://djangosnippets.org/snippets/862/<p>.</p>
<p>.</p>
<p>For use with <a href="http://shortwaveapp.com/">Shortwave</a>. Add this to your hosted <code>wave.txt</code> for a search of the current Django docs.</p>
Freely redistributableFormMail Clone
2008-03-25T13:59:49.773276-05:00baumer1122https://djangosnippets.org/snippets/664/<p>A quickie clone of good old fashion <a href="http://www.scriptarchive.com/formmail.html">Formmail.pl</a> any form that is a subclass of FormMail will have its conents emailed to all staff members on the site.</p>
Freely redistributableescapejs block tag
2008-02-26T12:01:53.253999-06:00baumer1122https://djangosnippets.org/snippets/617/<p>Block tag version of <a href="http://www.djangoproject.com/documentation/templates/#escapejs">escapejs</a>. Handy when using inclusion tags to generate AJAX responses.</p>
Freely redistributableFeed Reader Inclusion Tag with Caching
2007-08-24T13:15:54.344363-05:00baumer1122https://djangosnippets.org/snippets/384/<p>A revisit of <a href="http://www.djangosnippets.org/snippets/311/">the original snippet</a> with simple caching.
</p>
Freely redistributableHierarchical page slugs
2007-08-10T15:41:40.915820-05:00baumer1122https://djangosnippets.org/snippets/362/<p>This allows for urls in the form of <code>/grandparent-slug/parent-slug/self-slug/</code> where the number of parent slugs could be 0 to many.</p>
<p>You'll need to make sure that it is your last urlpattern because it is basically a catch-all that would supersede any other urlpatterns.</p>
<p>Assumes your page model has these two …</p>
Freely redistributableFeed Reader Inclusion Tag
2007-07-12T13:13:44.641089-05:00baumer1122https://djangosnippets.org/snippets/311/<p>This is an inclusion tag that can be used to pull in posts from any feed to a template. It doesn't do any caching, so it may slow down page load times.
Depends on <a href="http://www.feedparser.org">Feedparser</a>.
</p>
<p>Template usage:
{% pull_feed 'http://www.djangosnippets.org/feeds/latest/' 3 %}
</p>
Freely redistributable