-
Notifications
You must be signed in to change notification settings - Fork 47
auto creation of translated fields #164
Comments
Hey @w4mike , I can see 3 options here:
|
Hi @bellini666 , many thanks for your reply. I will have a look into the three options. For now option 2 and 3 look most promising to me. Is there a way to extend the field lookup, so I can use How would I get the Thx, |
You can define them as functions and get the model using the For example: @gql.django.type(SomeDjangoModel)
class SomeDjangoType:
@gql.django.field
def translatable_field(self, root: SomeDjangoModel, lang: str = "en"):
with override(lang):
return root.translatable_field |
In the example above, you can query it like: someDjangoType {
translatableField
translatableFieldEn: translatableField(lang: "en")
translatableFieldDe: translatableField(lang: "de")
...
} |
Hi @bellini666 , many thanks for your input. I have written an external resolver which I can reuse for any translated field. |
Hi,
I just started a private project using django with strawberry-django-plus.
I would like to use django-translated-fields for translation of some fields in this project.
The reason why I want to use this project is, because it does not introduce too much overhead.
However, I have a glue how to create a field and a resolver for the translated fields, but I would like to also 'automagically' add the fields per language created by this project in the model to the type definition in my strawberry schema.
Can you give me a hint how to do it ?
This would also probably solve my problem when I later want to introduce django-pghistory, where I need to create new types for the history events.
Appreciate all help and answers.
Thanks,
mike
The text was updated successfully, but these errors were encountered: