from django.db import models

from .compat import User


class Switch(models.Model):

    label = models.CharField(max_length=200)
    description = models.TextField(
        help_text='Short description of what this switch is doing', blank=True)
    globally_active = models.BooleanField(default=False)

    users = models.ManyToManyField(
        User, null=True, related_name='available_switches')

    def __unicode__(self):
        return self.label

from django.db import models

from .compat import User


class Switch(models.Model):

    label = models.CharField(max_length=200)
    description = models.TextField(
        help_text='Short description of what this switch is doing', blank=True)
    globally_active = models.BooleanField(default=False)

    users = models.ManyToManyField(
        User, null=True, related_name='available_switches', blank=True)

    def __unicode__(self):
        return self.label

Allow no selected users when editing a switch.
Allow no selected users when editing a switch.

  from django.db import models
  
  from .compat import User
  
  
  class Switch(models.Model):
  
      label = models.CharField(max_length=200)
      description = models.TextField(
          help_text='Short description of what this switch is doing', blank=True)
      globally_active = models.BooleanField(default=False)
  
      users = models.ManyToManyField(
-         User, null=True, related_name='available_switches')
+         User, null=True, related_name='available_switches', blank=True)
  
      def __unicode__(self):
          return self.label
  
Allow no selected users when editing a switch.
## Code Before:
from django.db import models

from .compat import User


class Switch(models.Model):

    label = models.CharField(max_length=200)
    description = models.TextField(
        help_text='Short description of what this switch is doing', blank=True)
    globally_active = models.BooleanField(default=False)

    users = models.ManyToManyField(
        User, null=True, related_name='available_switches')

    def __unicode__(self):
        return self.label

## Instruction:
Allow no selected users when editing a switch.
## Code After:
from django.db import models

from .compat import User


class Switch(models.Model):

    label = models.CharField(max_length=200)
    description = models.TextField(
        help_text='Short description of what this switch is doing', blank=True)
    globally_active = models.BooleanField(default=False)

    users = models.ManyToManyField(
        User, null=True, related_name='available_switches', blank=True)

    def __unicode__(self):
        return self.label
