djangosnippets.org: Latest snippets posted by zvoasehttps://djangosnippets.org/users/zvoase/2008-09-22T08:03:01.254625-05:00zvoaseFormHandler - take the legwork out of form processing
2008-09-22T08:03:01.254625-05:00zvoasehttps://djangosnippets.org/snippets/1075/<p>Take the legwork out of processing forms.</p>
<p>Most people have a very specific structure to how they process forms in views. If the request method is "GET", then some HTML (with the blank form) is rendered. If the method is "POST", then the form is validated. If the form is …</p>
Freely redistributableResource
2008-09-21T15:47:32.549022-05:00zvoasehttps://djangosnippets.org/snippets/1072/<p>The <code>Resource</code> class is a way of writing a Django view as a class. I've done this as part of an effort to write easier-to-understand RESTful apps, as this allows the grouping of similar views as different types of operation on a resource. Essentially, the solution goes something like this: …</p>
Freely redistributableCustomQueryManager
2008-07-13T13:32:42.650973-05:00zvoasehttps://djangosnippets.org/snippets/879/<p>A <code>models.Manager</code> subclass that helps to remove some of the boilerplate involved in creating managers from certain queries. Usually, a manager would be created by doing this:</p>
<pre><code>class MyManager(models.Manager):
def get_query_set(self):
return super(MyManager, self).get_query_set().filter(query=blah)
</code></pre>
<p>Other managers may return other query sets, but this is especially useful as one may define …</p>
Freely redistributable