Ticket #4189: models.py.diff

File models.py.diff, 1.1 KB (added by Brett Hoerner <bretthoerner@…>, 18 years ago)

get_absolute_url() patch

  • django/contrib/comments/models.py

     
    106106        return "%s: %s..." % (self.user.username, self.comment[:100])
    107107
    108108    def get_absolute_url(self):
    109         return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     109        try:
     110            return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     111        except AttributeError:
     112            return ""
    110113
    111114    def get_crossdomain_url(self):
    112115        return "/r/%d/%d/" % (self.content_type_id, self.object_id)
     
    191194        return "%s: %s..." % (self.person_name, self.comment[:100])
    192195
    193196    def get_absolute_url(self):
    194         return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     197        try:
     198            return self.get_content_object().get_absolute_url() + "#c" + str(self.id)
     199        except AttributeError:
     200            return ""
    195201
    196202    def get_content_object(self):
    197203        """
Back to Top