mercredi 29 juillet 2020

How to set a field will be change by if statement in models for Django?

I have a field in models that the True/False value will be affect by other field. May I know how to set it?

models.py:

class Product(models.Model):
  storage_amount = models.PositiveIntegerField()
  if storage_amount == 0 or None:
    out_of_storage_or_not = models.BooleanField(default=True)
  else:
    out_of_storage_or_not = models.BooleanField(default=False)

Aucun commentaire:

Enregistrer un commentaire