Snippet List
This class decorator will help you when you want to keep a unique boolean (think a 'default' field which should only be only one set to true in a group).
The interesting thing with this, is that it's possible to assign a subset of fields to be used, so that the uniqueness of the field will be guaranteed among only the subset (look at the Example section in the code to understand this behaviour).
This is a better and improved way of doing http://djangosnippets.org/snippets/2676/
In our situation, we want the user to choose either yes or no. The only requirement is that they fill out the form. It is _not_ required that they answer True/Yes.
The BooleanField treats None and False as False; The NullBooleanField distinguishes between None and False, but it doesn't raise any validation errors.
Subclassing the NullBooleanField was better than overriding the clean method on all of our NullBooleanField instances.
- required
- boolean
- bool
- boolean-field
- null-boolean-field
Something I end up doing all the time, making a boolean variable show up as a nice image. With this code you can do the following:
`{% boolean_img user.is_active %}`
And get the following output:
`<img src="/media/icons/accept.png" alt="True" />`
All you need to do is use the custom templatetag code, load it in your template and use the `boolean_img` tag.
**Adjust templates, html and images where needed**
- image
- templatetag
- boolean
- flag
4 snippets posted so far.