I'm trying to implement Django sitemaps and want to use the ping google when my sitemap is updated. I'm little confused about how to write the save method in my models whenever a new doctor entry is added to the database.
Here is my models.py file
class Doctor(models.Model):
name = models.CharField(max_length=1300)
specialization = models.ForeignKey(Specialization)
clinic = models.ForeignKey(Clinic)
seekers = models.ManyToManyField(User, through='UserContent')
language = models.ManyToManyField(Language)
scope = models.CharField(max_length=1300, null = True, blank = True)
education1 = models.CharField(max_length=1300)
gender_choices = ( ('Male', 'Male'), ('Female','Female'),)
gender = models.CharField(max_length=15, choices = gender_choices, null=True, blank = True)
image = models.ImageField(upload_to='uploads/', null=True, blank = True)
mimetype = models.CharField(max_length=20)
submitted_on = models.DateTimeField(auto_now_add=True, null = True, blank = True)
def __unicode__(self):
return u"%s %s" % (self.name, self.specialization)
def get_absolute_url(self):
from django.core.urlresolvers import reverse
return reverse('meddy1.views.showDocProfile', args=[str(self.id)])
Don't override the save method. Better, use signals, more specifically, the post_save signal.