0

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)])
James L.
  • 1,143
  • 22
  • 52

1 Answers1

0

Don't override the save method. Better, use signals, more specifically, the post_save signal.

dekomote
  • 3,817
  • 1
  • 17
  • 13
  • I tried doing post_save(ping_google('/sitemap.xml'), sender=Doctor, dispatch_uid=DOCTOR_PING_GOOGLE) but I get an HTTP Error 400: Bad Request – James L. Aug 15 '14 at 19:33