Login

Snippets by kunitoki

Snippet List

Active page class for selected menu items

Simple tag to check which page we are on, based on resolve: useful to add an 'active' css class in menu items that needs to be aware when they are selected. Typical usage is like: ` <ul> <li class="{% active request "myapp:myview1" %}">My View 1</li> <li class="{% active request "myapp:myview2" %}">My View 2</li> </ul> `

  • templatetag
  • menu
  • tab
Read More

True Unique Boolean Model Decorator

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/

  • model
  • unique
  • boolean
Read More

True Unique Boolean Decorator

Useful when you want to keep only one instance of a model to be the default one. This is a decorative way of doing the same as in http://djangosnippets.org/snippets/1830/ Can this be made better as a class decorator (not having to declare explicitly the save method) ?

  • model
  • unique
  • boolean
Read More

Improved Button Admin

An improved version of http://djangosnippets.org/snippets/1016/ which lets you add separate buttons for change_list and change_form pages in the admin.

  • admin
  • buttons
Read More

kunitoki has posted 4 snippets.