title: Change the value of a field in a class depending on the result of a function
body: <p>how can I modify the value of a boolean field of a class depending on the result of a function?</p>
  <p>What I am trying to do is a function that ping (icmp) an ip that is in the 'Cliente' class and depending on the result, change the value 'ping_status' in the class.</p>
  <p>I'm new to python, so I don't have a lot of knowledge, and I've been trying to do this for 1 week, but I can't.</p>
  <p>models.py</p>
  <pre><code>class Cliente(models.Model):
  razon_social = models.CharField('Razon Social', max_length=50)
  numero_cuenta = models.CharField('Numero de cuenta',max_length=6)
  nombre_contacto = models.CharField('Nombre del contacto', max_length=50)
  numero_del_contacto = models.CharField('Numero del contacto', max_length=10)
  email = models.EmailField('Correo Electronico', blank=True, null=True)
  tiene_as_propio = models.BooleanField('Tiene ASN priopio', default=False)
  ipv4 = models.GenericIPAddressField('IP', default='192.168.0.0')
  segmento = models.CharField('Segmento', max_length=15)
  asn= models.CharField(max_length=6, blank=True, null=True)
  created = models.DateTimeField('Creado el', auto_now_add=True ,blank=True, null=True)
  updated = models.DateTimeField('Actualizado el', auto_now_add=True, blank=True, null=True)
  topologia = models.FileField('Topologia', blank=True, null=True)
  ping_status = models.BooleanField('Ping', blank=True, null=True)
  
  
  def Meta(self):
      verbose_name = 'cliente'
      verbose_name_plural = 'clientes'
  
  def __str__(self):
      return self.razon_social
  </code></pre>
  <p>My function looks like this:</p>
  <pre><code>def do_ping():
      &quot;&quot;&quot;Realice un nuevo ping y guárdelo en la base de datos.&quot;&quot;&quot;
      ip_clientes = Cliente.objects.values_list('ipv4')
  
      for ip in ip_clientes:
          ip = (list(ip))
          for ping in ip:
              ping = subprocess.call(['ping', '-n', '1', '-w', 
                                                    '2',ping],
                                                stdout=open(os.devnull, 'w'),
                                                stderr=open(os.devnull, 'w'))
  </code></pre>
  <p>But after this I don't know what to do to get the class value and modify it</p>
  <p>Regards</p>