#15084: Unnecessary imports lead to ImportError
--------------------------------------+------------------------------------
Reporter: vanschelven | Owner: nobody
Type: Bug | Status: reopened
Component: Internationalization | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by ramiro):
Replying to [comment:20 vanschelven]:
> [...] Especially the fact that uggettext() & friends may trigger this
makes this a hairy bug: uggettext is often used in the middle of a module
or class definition.
FWIW, since 1.4 we have a
[https://docs.djangoproject.com/en/1.4/topics/i18n/translation/#lazy-
translation note] precisely about this in our i18n docs:
Lazy translation
Use the lazy versions of translation functions in
django.utils.translation (easily recognizable by the lazy suffix in their
names) to translate strings lazily -- when the value is accessed rather
than when they're called.
These functions store a lazy reference to the string -- not the actual
translation. The translation itself will be done when the string is used
in a string context, such as in template rendering.
This is essential when calls to these functions are located in code
paths that are executed at module load time.
This is something that can easily happen when defining models, forms and
model forms, because Django implements these such that their fields are
actually class-level attributes. For that reason, make sure to use lazy
translations in the following cases:
* Model fields and relationships verbose_name and help_text option
values
* Model verbose names values
* Model methods short_description attribute values
--
Ticket URL: <https://code.djangoproject.com/ticket/15084#comment:23>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.