I have 2 models:
class Producer(models.Model):
def __unicode__(self):
return self.name
def get_absolute_url(self):
return "/prod/%i/" % self.id
name = models.CharField(max_length=10, unique=True)
class Car(models.Model):
def __unicode__(self):
return self.name
def get_absolute_url(self):
return "/prod/%s/car/%i" % Producer.id, self.id
name = models.CharField(max_length=10, unique=True)
prod = models.ForeignKey(Producer)
On /sitemap.xml I have an error: type object 'Producer' has no attribute 'id'. How to get in the method get_absolute_url (of Car class) id of the Producer? Thanks. I try Producer_id, Producer__id but it doesn’t works.
It should be:
Also looking into your code there can be done two more improvements:
/prod/%s/car/%swhich is a bad way to do.