def toggle_switch(name, active=True):
 (switch, created) = Switch.objects.get_or_create(name=name, defaults={'active': active})
 if (not created):
  switch.active = (not switch.active)
  switch.save()
 return switch

def toggle_switch ( name , active = True ) : ( switch , created ) = Switch . objects . get_or_create ( name = name , defaults = { 'active' : active } ) if ( not created ) : switch . active = ( not switch . active ) switch . save ( ) return switch
activate or deactivate a waffle switch .