Python Django 1.6:当站点地图更新时,如何ping google?
我正在尝试实现Django,并希望在更新我的站点地图时使用ping google。每当向数据库中添加新的医生条目时,我对如何在模型中编写save方法有点困惑 这是我的models.py文件Python Django 1.6:当站点地图更新时,如何ping google?,python,django,django-sitemaps,Python,Django,Django Sitemaps,我正在尝试实现Django,并希望在更新我的站点地图时使用ping google。每当向数据库中添加新的医生条目时,我对如何在模型中编写save方法有点困惑 这是我的models.py文件 class Doctor(models.Model): name = models.CharField(max_length=1300) specialization = models.ForeignKey(Specialization) clinic = models.Foreign
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)])
不要重写save方法。更好的方法是,更具体地说,使用post_save信号。我尝试了post_save(ping_google('/sitemap.xml'),sender=Doctor,dispatch\u uid=Doctor\u ping_google),但我收到一个HTTP错误400:请求不正确