hugo wrote:
> >Are you sure? Because now it throws a NameError exception.
> >global name 'gettext_lazy' is not defined
>
> Yes, I am sure. I wrote that stuff ;-)
>
I'm convinced.

> >>> from django.utils.translation import gettext_lazy, activate
> >>> activate('de-de')
> >>> print gettext_lazy('Username:')
> Benutzer:
>
> So you just need to pull in the gettext_lazy function and use that
> directly instead of renaming it to _ - then it should work fine. Only
> problem with model code: "Using module globals in models". Look at the
> named chapter on http://code.djangoproject.com/wiki/DataModelPitfalls.
> You can only use functions from your modules global namespace, if you
> pass them on to the model in the right way.

Does this mean I have to use this in all the models?
class META:
    module_constants = {
        'gettext_lazy': gettext_lazy
    }

- or -

def __repr__(self):
        from django.utils.translation import gettext_lazy
        return gettext_lazy("blah")

> This problem will go away
> with magic-removal.

It doesn't sound like magic, but I'll be glad when it's gone :)

-janr

Reply via email to