from django.utils.translation import ugettext_lazy as _def toggle_publish(request,action,post_id): try: post = Post.objects.get(id = post_id) if action=='publish': post.status = 1 post.save() messages.success(request, _('The post was published successfully!')) elif action == 'unpublish': post.status = 0 post.save() messages.success(request, _('The post was unpublished!')) except Post.DoesNotExist: messages.error(request, _('You are not authorized to publish/unpublish this post!')) return HttpResponseRedirect('/list_posts/')
The problem is that the message is always displayed in English, even though the current language is different.
The strange thing is that when I visit the url for lets say publish, two or more times consequently the message is displayed in the correct language after the first time.
But clicking publish, than unpublish (which is the normal flow) shows the message only in English.
Do you have any ideas what could be causing this?
Thanks