from django.shortcuts import render
def my_view(request):
context = {}
return render(request, "template.html", context)
def save(self, *args, **kwargs)
self.ac_total = self.period_duration()
super(Accessories, self).save(*args, **kwargs)
from django.db.models.signals import pre_save
from django.dispatch import receiver
@receiver(pre_save, sender=Accessories)
def calc_ac_total(sender, instance, **kwargs):
instance.ac_total = instance.period_duration()