[Answer]-Django updating a status from within a model

1👍

class Batch(model.Model):
    STATUSES_CHOICES = (
        ('Pending', 'Pending'),
        ('Complete', 'Complete'),
        ('Failed', 'Failed'),
        ('Cancelled', 'Cancelled'),
    )
    status = models.CharField(max_length=25, choices=STATUS_CHOICES)
    # The rest of the fields..

    def complete_update(self):
        self.status = 'Complete'
        self.save()

That should do it

Edit: As mentioned by karthikr a post_save might be a better way to go about this

Leave a comment