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.
- [Django]-Problems for parse POST json message Django/GAE
- [Django]-Sentry delete issues (logs)
- [Django]-Django Temporary Images
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
- [Django]-Django duplicate queries with manager related
- [Django]-How to create a Factory-Boy factory for a model with TaggableManager field
- [Django]-How to customize a filter's name displayed in admin site in Django?
Source:stackexchange.com