FOr the other issue, I changed https://gitlab.com/mailman/hyperkitty/-/blob/master/hyperkitty/views/thread....
From: if request.user.is_authenticated: last_view_obj, created = LastView.objects.get_or_create( thread=thread, user=request.user) if not created: last_view = last_view_obj.view_date last_view_obj.save() # update timestamp
to: if request.user.is_authenticated: try: last_view_obj, created = LastView.objects.get_or_create( thread=thread, user=request.user) except LastView.MultipleObjectsReturned: last_view_duplicate, last_view_obj = LastView.objects.filter( thread=thread, user=request.user).order_by("view_date").all() last_view_duplicate.delete() created = False
if not created:
last_view = last_view_obj.view_date
last_view_obj.save() # update timestamp
and that seems to have fixed it.
I've been thinking though that it'd be better to fix duplicates in the LastView class rather than on every get() or get_or_create() call.
Peter C