[Answer]-Id of the another class in Django

1👍

It should be:

def get_absolute_url(self):
    return "/prod/%s/car/%s" % (self.prod.id, self.id)

Also looking into your code there can be done two more improvements:

  1. Model class method should come after the fields
  2. You should use reverse-resolution-of-urls instead of hard coding the url /prod/%s/car/%s which is a bad way to do.

Leave a comment