Hi Django developers,
i am new in Python,
i want to develop a simple app stock management.
can you give me a brief idea how to add device to stock if it hasnt assigned to employee
i have below models
class Device(models.Model):
STATUS = (
('in use', in use),
('available', 'available')
)
status =models.Charfield(choices=STATUS, max_length=32)
name = models.Charfield(max_length=32)
class Employee(models.Model):
name = models.Charfield(max_length=32)
class Assign(models.Model):
notebook = models.ForeignKey('
Device ', on_delete=models.CASCADE)
subscriber = models.ForeignKey('Employee', on_delete=models.CASCADE)
class Stock(models.Model):
pass
I want if device is already has subscribers then aply its status to 'in_use' and remove it from Stock model and if device status is available then move it to Stock