djangosnippets.org: Latest snippets tagged with 'helper'http://djangosnippets.org/tags/helper/2011-07-25T18:14:34.443512-05:00Django load global fixtures test helper
2011-07-25T18:14:34.443512-05:00vazhttp://djangosnippets.org/snippets/2496/<p>This lets you load global fixtures from a directory you set as <code>FIXTURES_ROOT</code> in your settings.py.</p>
<p>For example, setting <code>FIXTURES_ROOT</code> to <code>/path/to/myproject/fixtures/</code></p>
<p>I tend to like to keep fixtures that should be loaded when a new instance of a site is deployed, but not auto-loaded (so they won't rewrite any …</p>
Freely redistributableModifying the fields of a third/existing model class
2010-12-26T19:30:38.031433-06:00marinhohttp://djangosnippets.org/snippets/2300/<p>You can extend the class <strong>ModifiedModel</strong> to set new fields, replace existing or exclude any fields from a model class without patch or change the original code.</p>
<p><strong>my_app/models.py</strong></p>
<pre><code>from django.db import models
class CustomerType(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Customer(models.Model):
name = models.CharField(max_length=50)
type = models.ForeignKey('CustomerType')
is_active …</code></pre>
Freely redistributablesql to dict
2009-03-20T16:34:36.943902-05:00amituhttp://djangosnippets.org/snippets/1383/<p>A helper utility, does what name says. </p>
Freely redistributableupdate_or_create
2008-10-07T13:35:31.738669-05:00abhin4vhttp://djangosnippets.org/snippets/1114/<p>Django provides a <code>get_or_create</code> helper method in the <code>models.Manager</code> class which looks up an object for the given <code>kwargs</code>, creating one if necessary. But sometime you need a method which updates the object with given <code>kwargs</code> or creates it if it's not found. This snippet provides the helper for …</p>
Freely redistributableget_model_or_404
2008-08-28T09:41:16.884575-05:00blackbrrrhttp://djangosnippets.org/snippets/1007/<p>Attempt to get a model from the <code>AppCache</code> and raise <code>Http404</code> if it cannot be found.</p>
Freely redistributablehtml helpers for images and links
2007-10-09T09:12:21.599117-05:00buriyhttp://djangosnippets.org/snippets/441/<p>link and img are both HTML construction helpers.
Good idea to use these helpers if your html don't fit into templates.</p>
Freely redistributable