Django admin object change action

I am developing a courier management service using Django. So far, I have made three models,

  1. Customer
  2. DelveryAgent
  3. Parcels.

Here is the Parcel model:

class Parcel(models.Model):
    type = models.CharField(max_length=20)
    city = models.CharField(max_length=20)
    street = models.CharField(max_length=100)
    zip = models.CharField(max_length=100)
    email = models.CharField(max_length=100)
    phone = models.CharField(max_length=100)
    status = models.CharField(max_length=100, choices=STATUS, default='pending')
    booked_by = models.ForeignKey(Customer, on_delete=models.CASCADE)
    delivery_agent = models.ForeignKey(DeliveryAgent)

Customers can place new parcels. Initially, the parcel status is pending, and no delivery agent is assigned. When the admin assigns a new delivery agent to the parcel from the admin site, I want the relative customer to get notified with the details of the delivery agent. How can I do that?

You have the ModelAdmin.save_model method that you can override to perform your “notification process” whenever a save is done in a particular model admin class.

1 Like

I got it. Thanks a lot.