[Django]-AssertionError: Negative indexing is not supported

3👍

This will happen mostly when you are trying some indexing related operation on an empty list. Try this instead:

somelist=[]
last_element = somelist[len(somelist)-1]

1👍

It looks like you are coming across this issue in django-cms. It’s been fixed now, so you could upgrade to the latest release, or manually apply the patch.

You might have to upgrade django-mptt to 0.5.2 at the same time.

0👍

instead of using a negative reference just reverse the list such that the last item becomes the first and then use a positive index to access it just like as shown below. I hope this was helpful

last_response = Model.objects.filter(author=request.user).order_by("-id")[0].message

Leave a comment