First time here? Check out the FAQ!

Revision history  [back]

Viewing deleted question from an anonymoususer internal error

When an AnonymousUser (like googlebot) or any not signed in user attempts to visit a link to a deleted post there is an internal error.

The error is an AttributeError in this file: on line 395

        show_comment = models.Post.objects.get_comments().get(id=show_comment)
    except models.Post.DoesNotExist:
        error_message = _(
            'Sorry, the comment you are looking for has been '
            'deleted and is no longer accessible'
        request.user.message_set.create(message = error_message)
        return HttpResponseRedirect(question_post.thread.get_absolute_url())

the line request.user.message_set.create(message = error_message) will raise an AttributeError if request.user is AnonymousUser because it does not have the message_set property.