djangosnippets.org: Latest snippets posted by powderflaskhttp://djangosnippets.org/users/powderflask/2019-06-20T12:59:27.054338-05:00powderflaskStrict Boolean Form Field
2019-06-20T12:59:27.054338-05:00powderflaskhttp://djangosnippets.org/snippets/10672/<p>A form field for a Boolean that forces the user to make a choice from a list of choices.</p>
<p><strong>Use Case</strong></p>
<p>You have a Yes/No question the user must answer, but they may answer it yes or no. You don't want to supply a default because your need to force …</p>
Freely redistributableCBV decorator from view function decorator
2017-10-03T13:43:53.250581-05:00powderflaskhttp://djangosnippets.org/snippets/10624/<p>The Mixin approach for applying permissions to CBV views suffers from 3 issues:</p>
<ol>
<li>you need to read the code to see what permissions are being applied to a View</li>
<li>multiple bits of disparate code required to specify, e.g., a simple permission check</li>
<li>permissions set on a base class are overridden …</li></ol>
Freely redistributableUse DB Test Runner
2015-12-26T14:38:25.771116-06:00powderflaskhttp://djangosnippets.org/snippets/10544/<p><strong>Use Case</strong>: Specify the DB to run tests against. For example, use a legacy DB (un-managed), or a read-only DB where it is un-important to test creation, but important to test connection, trigger functions, and that models match schema.</p>
<p><strong>Usage</strong>: in DATABASES setting, add:</p>
<pre><code>'TEST' :{
'USEDB': 'your_test_DB_name_here', …</code></pre>
Freely redistributable