psycopg2 throws an "can't adapt" error on ugettext_lazy translated strings
|Reported by:||mitar||Owned by:||nobody|
|Cc:||mmitar@…, phartig@…, poswald||Triage Stage:||Accepted|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I have a custom model field (based on a CharField) for which I am setting a default value to a string I want for it to be translated for each user based on her language settings.
So in definition of my custom field I do something like:
class CustomField(fields.CharField): def __init__(self, *args, **kwargs): ... kwargs.setdefault('default', ugettext_lazy('Default value')) ... super(fields.CustomField, self).__init__(*args, **kwargs) def get_internal_type(self): return "CharField"
Sadly this fails when creating a default (empty) object with get_or_create. psycopg2 raises "can't adapt" error where it is visible that proxy object was passed as an argument.
Change History (15)
comment:1 Changed 4 years ago by mitar
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset
comment:11 Changed 3 years ago by poswald
- Cc poswald added
- Severity set to Normal
- Triage Stage changed from Design decision needed to Accepted
- Type set to Bug