djangosnippets.org: Latest snippets posted by danfairshttps://djangosnippets.org/users/danfairs/2008-01-01T13:38:16-06:00danfairsnewforms and ModelForm2008-01-01T13:38:16-06:00danfairshttps://djangosnippets.org/snippets/530/<p>I noticed that form_for_* in newforms now carry deprecation warnings. This code is a minimal demonstration of how to use ModelForm as a replacement.
</p>
<p>Full information can be found on <a href="http://www.stereoplex.com/two-voices/django-modelform-and-newforms">Stereoplex</a>. Hope this helps you.
</p>
Freely redistributableSessions and authentication without cookies2007-11-07T14:39:03-06:00danfairshttps://djangosnippets.org/snippets/460/<p><a href="http://www.djangoproject.com/documentation/sessions/">The Session documentation</a> rightly warns of the dangers of putting a session ID into a query string. Sometimes, however, you have to do it - perhaps your client has mandated support for browsers with cookies disabled, or perhaps (as in my case) you're just dealing with a slightly broken client ...</p>
Freely redistributableUPDATED: Django Image Thumbnail Filter2007-10-30T09:47:45-05:00danfairshttps://djangosnippets.org/snippets/453/<p>A Django image thumbnail filter, adapted from code by <a href="http://batiste.dosimple.ch/blog/2007-05-13-1/">Batiste Bieler</a>.
</p>
<p>This updated version drops support for cropping and just rescales. You should use it in your templates like this:
</p>
<p><code>&lt;img src='{{ MEDIA_URL }}{{ image.get_image_filename|thumbnail:"300w,listingimages" }}' alt="{{ image.title }}" title="{{ image.title }}" /&gt;</code>
</p>
<p>This will produce a 300-pixel wide ...</p>
Freely redistributable