djangosnippets.org: Latest snippets posted by dballanchttps://djangosnippets.org/users/dballanc/2007-11-06T14:11:13.435714-06:00dballancCopy/Paste form generation
2007-11-06T14:11:13.435714-06:00dballanchttps://djangosnippets.org/snippets/458/<p>Generator to help make newforms classes a bit like inspectdb does for generating rough model code. This is a standalone script to go in your project directory with settings.py and called from the prompt. It looks up the model, and generates code to copy/paste into your app. Hopefully to make …</p>
Freely redistributableMiddleware for printing of exception to console
2007-09-18T12:44:43.160192-05:00dballanchttps://djangosnippets.org/snippets/420/<p>The django debug screens are great, but only when you can see them. Trying to debug javascript/ajax calls can be kind of a pain. This just a copy/paste of some code in django's internals stuck in a middleware so that exceptions also print to the dev server console.</p>
Freely redistributableInstance partial update
2007-09-09T20:19:50.185736-05:00dballanchttps://djangosnippets.org/snippets/409/<p>If you're like me, you've got a models with a lot of fields/foreignkeys and often only want to edit a portion of the model in a form. Add this method to your custom form class and use it in place of the save() method.</p>
Freely redistributableInspect object debugging tag
2007-07-09T16:52:49.976930-05:00dballanchttps://djangosnippets.org/snippets/306/<p>Simple template tag that allows you to inspect an object in the context for debugging. It will inspect django models and forms using introspection. Dicts and lists are formatted to truncate long data. Pretty much everything else just displays the <strong>str</strong> representation + class name.</p>
<p>Example output: http://dsanity.net/introspectiontag.html</p>
<p>Usage:</p>
<p>put …</p>
Freely redistributableTimedelta template tag
2007-04-30T13:03:21.040796-05:00dballanchttps://djangosnippets.org/snippets/210/<p>This is tag similar to <em>timesince</em> and <em>timeuntil</em>, which work great until you starting giving timesince dates in the future or timeuntil dates in the past. Timedelta tag will humanize output correctly for both future and past dates using <em>now</em> as a default reference date (or a specified reference …</p>
Freely redistributableDynamic Form Class
2007-03-31T00:26:30.847819-05:00dballanchttps://djangosnippets.org/snippets/148/<p>Nutshell: Subclass this form with the required fields defined to automatically generate a form based on a model in a similar fashion to how form_for_model works, but in a way that tries to be a little easier if you want to customize the form. It handles updates and creations automatically …</p>
Freely redistributable