Hi, 
Everywhere else in my project where I use django messages framework and 
translation everything works like charm, except this one place. 
I have a simple view like this:

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1cd41a82-b6a7-4ab9-ab5d-b40231dc7a05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to